Please compile the attached code
Created attachment 25254 [details] Just compile it
c the following is wrong: the MOLD formal argument of null() is required c gfortran simply picks the last routine defined in the interface, in this case s2 Which is consistent with NAG, Open64 and PathScale. With ifort and g95 one gets the expected error message: call gen(null()) 1 Error: Typeless NULL() at (1) must have a MOLD argument call gen(null()) 1 Error: Generic subroutine 'gen' at (1) is not consistent with a specific subroutine interface error #6285: There is no matching specific subroutine for this generic subroutine call. [GEN] * * * From F2008's 13.7.125 NULL ([MOLD]): "If MOLD is absent, the characteristics of the result are determined by the entity with which the reference is associated. See Table 13.2. MOLD shall not be absent in any other context. [...]" "If the context of the reference to NULL is an actual argument in a generic procedure reference, MOLD shall be present if the type, type parameters, or rank are required to resolve the generic reference." "Table 13.2: Characteristics of the result of NULL ( ) Appearance of NULL ( ) Type, type parameters, and rank of result: right side of a pointer assignment pointer on the left side initialization for an object in a declaration the object default initialization for a component the component in a structure constructor the corresponding component as an actual argument the corresponding dummy argument in a DATA statement the corresponding pointer object"
Created attachment 25262 [details] Draft patch This patch handles NULL() properly, including passing it to optional nonpointer, nonallocatable dummies. Caveat: It currently prints two messages - I don't want to have the second one. call gen(null()) 1 Error: MOLD= required in NULL() argument at (1): Ambiguity between specific functions s2 and s1 call gen(null()) 1 Error: There is no specific subroutine for the generic 'gen' at (1)
(In reply to comment #1) > Created attachment 25254 [details] > Just compile it Please paste the code content directly instead of attaching for small (say, less than around 10-20 lines) files. Related bugs: PR34547 (and it's duplicate PR44349 reported by the same author as this one). Unfortunately, they won't be fixed by Tobias' comment #3 patch. (In reply to comment #3) > Created attachment 25262 [details] > Draft patch > I think we'll be in trouble if there are more than one null argument. Otherwise looks good.
Author: burnus Date: Wed Sep 14 06:26:07 2011 New Revision: 178841 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178841 Log: 2011-09-14 Tobias Burnus <burnus@net-b.de> PR fortran/34547 PR fortran/50375 * check.c (gfc_check_null): Allow allocatables as MOLD to NULL. * resolve.c (resolve_transfer): Reject NULL without MOLD. * interface.c (gfc_procedure_use): Reject NULL without MOLD if no explicit interface is known. (gfc_search_interface): Reject NULL without MOLD if it would lead to ambiguity. 2011-09-14 Tobias Burnus <burnus@net-b.de> PR fortran/34547 PR fortran/50375 * gfortran.dg/null_5.f90: New. * gfortran.dg/null_6.f90: New. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/check.c trunk/gcc/fortran/interface.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Author: burnus Date: Wed Sep 14 06:27:25 2011 New Revision: 178842 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178842 Log: Really add: 2011-09-14 Tobias Burnus <burnus@net-b.de> PR fortran/34547 PR fortran/50375 * gfortran.dg/null_5.f90: New. * gfortran.dg/null_6.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/null_5.f90 trunk/gcc/testsuite/gfortran.dg/null_6.f90
FIXED on the trunk (for 4.7). Thanks for the report!