(Follow up from 41777, comment 10) The following variable_check in check.c does not make much sense: if ((e->expr_type == EXPR_VARIABLE && e->symtree->n.sym->attr.flavor != FL_PARAMETER) || (e->expr_type == EXPR_FUNCTION && e->symtree->n.sym->result == e->symtree->n.sym)) return SUCCESS; I think the idea is to support function f() f = 4.0 end function f where this "f" is to regarded as variable. However, the test is also called outside of the function body of "f" (incl. internal procedures of f). In that case it does not make much sense. The following example shows this: For LOC(f) it prints the address of the function, for LOC(f()) the result of the function call; but it fails for LOC(g()) due to e->symtree->n.sym->result == e->symtree->n.sym (Ditto if "f" had a result variable.) * * * I think the proper fix would be a) To check whether is in the function body of "f" (incl. internal procedures of f) - and return FAILURE otherwise. b) Optionally: Also allow LOC() for function (i.e. pointer address of the function itself). Supporting LOC(f()) does not make much sense, except for debugging - if one allows the latter, one also needs to handle generic functions. * * * module m interface g module procedure f end interface g contains function f() integer, pointer :: f f => null() end function f end module m use m print *, loc(f) ! prints something like 4196132 print *, loc(f()) ! print 0 print *, loc(g()) ! Error: must be a variable end
> The following example shows this: For LOC(f) it prints the address of the > function, for LOC(f()) the result of the function call; but it fails for This is the case for gfortran 4.4 and 4.5, but 4.6 and trunk gives the following error pr42934.f90:14.13: print *, loc(f()) ! print 0 1 Error: 'x' argument of 'loc' intrinsic at (1) must be a variable What result do you expect? Is it a 4.6/4.7 regression?
> What result do you expect? Is it a 4.6/4.7 regression? Ping!
No answer since over a year and the code in comment #0 seems to be gone. Finally closing as fixed. Please reopen if I am missing something.