- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following (highly trimmed) code works on CVF/IVF but does not compile on some other compilers, which claim that it violates the F-95 standard. So I'd like to check if indeed this code violates the F-95 standard.
!=============
module m
implicit none
type parrType
integer,pointer::v(:)=>null()
endtype parrType
contains
!--
pure subroutine parrN(a,i0,i1,s,b)
implicit none
type(parrType),intent(in)::a(:)
integer,intent(in)::i0,i1
integer,intent(out)::s,b
s=size(a)
b=minval(a(1)%v(i0:i1))
endsubroutine parrN
!--
endmodule m
!=============
the error message applying to both executable statements (ie, 2 separate errors) was:
"a" must not be modified or used as a pointer target inside of a pure subprogram, because it is in common, a dummy argument, host associated, or use associated. >>
I wonder whether F-95 guarantees that intrinsics such as size and minval are pure and do not affect pointer arguments in the context of using them inside pure procedures. As far as I can see there can be no possible side effects with the code above...
thanks,
dmitri
!=============
module m
implicit none
type parrType
integer,pointer::v(:)=>null()
endtype parrType
contains
!--
pure subroutine parrN(a,i0,i1,s,b)
implicit none
type(parrType),intent(in)::a(:)
integer,intent(in)::i0,i1
integer,intent(out)::s,b
s=size(a)
b=minval(a(1)%v(i0:i1))
endsubroutine parrN
!--
endmodule m
!=============
the error message applying to both executable statements (ie, 2 separate errors) was:
"a" must not be modified or used as a pointer target inside of a pure subprogram, because it is in common, a dummy argument, host associated, or use associated. >>
I wonder whether F-95 guarantees that intrinsics such as size and minval are pure and do not affect pointer arguments in the context of using them inside pure procedures. As far as I can see there can be no possible side effects with the code above...
thanks,
dmitri
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The standard says:
"All intrinsic functions defined in this standard are pure."
I can't find any wording in the standard that would support calling this code non-conforming. It could be that the other compilers are misinterpreting the following constraint:
but that requires that the variable on the left side be the one of derived type with a pointer component, which is not the case here.
I suggest asking the other vendor(s) what their rationale is for this diagnostic.
"All intrinsic functions defined in this standard are pure."
I can't find any wording in the standard that would support calling this code non-conforming. It could be that the other compilers are misinterpreting the following constraint:
Constraint: In a pure subprogram any variable which is in common or accessed by host or use
association, is a dummy argument to a pure function, is a dummy argument with
INTENT (IN) to a pure subroutine, or an object that is storage associated with any
such variable, shall not be used in the following contexts:
...
(8) As the expr of an assignment-stmt in which the variable is of a derived type if the derived
type has a pointer component at any level of component selection;
but that requires that the variable on the left side be the one of derived type with a pointer component, which is not the case here.
I suggest asking the other vendor(s) what their rationale is for this diagnostic.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page