[Bug fortran/47876] New: Host-assoc generic subroutine plus intrinsic function not rejected
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 24 07:34:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47876
Summary: Host-assoc generic subroutine plus intrinsic function
not rejected
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/8e0240bbb7628ce2
Steve Lionel claims the code is invalid and NAG also rejects it, which is a
good indication that it is indeed invalid - even though at a glance I thought
the code is valid.
gfortran compiles the following without warning or error:
module hostassoc
implicit none
interface pack
module procedure pack_sub
end interface
contains
subroutine pack_sub ()
end subroutine pack_sub
subroutine foo (a)
integer, intent(in) :: a(:)
! intrinsic :: pack ! Try uncommenting this line...
print *, pack (a, a /= 0)
end subroutine foo
end module hostassoc
Steve wrote:
The key to this is paragraph number 5 on p286 of F2008 (12.4.3.4.5
Restrictions on generic declarations). It says:
Within the scope of a generic name that is the same as the generic name
of an intrinsic procedure, the intrinsic procedure is not accessible by
its generic name if the procedures in the interface and the intrinsic
procedure are not all functions or not all subroutines.
In your case with the INTRINSIC commented out, the PACK intrinsic is
made inaccessible because your generic PACK has a subroutine as one of
the interfaces. Since the intrinsic is inaccessible, the reference to
PACK as a function fails.
If you uncomment the INTRINSIC, then you are violating constraint C1215
(F2008) "Within the scope of a generic name, each pair of procedures
identified by that name shall both be subroutines or both be functions"
More information about the Gcc-bugs
mailing list