http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46478
Summary: Missing diagnosis for combining SUBROUTINE and FUNCTION in a GENERIC interface Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Found at: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/2084596e400fdf2d gfortran allows generic interfaces which combine FUNCTIONs with SUBROUTINEs. That's invalid Fortran, but allowed as vendor extension as it is not a constraint. gfortran diagnoses the problem if one does not use "(MODULE) PROCEDURE" but includes the declaration directly in the interface body - albeit the error message is not very clear: Error: SUBROUTINE at (1) does not belong in a generic function interface Other compiles: - NAG rejects it with Error: SUBR_NAME and FUNC_NAME must both be SUBROUTINEs or both be FUNCTIONs for generic NEW_NAME - g95 with Error: Interfaces of generic 'new_name' at (1) must all be FUNCTIONs or SUBROUTINEs - ifort has a warning -- and only with -stand f03: warning #7953: Standard Fortran requires that within a scoping unit, two procedures that have the same generic name shall both be subroutines or both be functions. [SUBR_NAME] Even with -std=f95, gfortran does not even issue a warning. Expected: - Reject it with -std=f95/f2008 - Consider print a warning by default for -std=gnu; printing an error would also be possible MODULE something INTERFACE new_name PROCEDURE func_name, subr_name END INTERFACE CONTAINS LOGICAL FUNCTION func_name(arg1,arg2) ! : END FUNCTION SUBROUTINE subr_name(arg1,arg2,arg3) ! : END SUBROUTINE END MODULE