[Bug fortran/54082] Program name shadows other entities with the same name

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 24 15:53:00 GMT 2012


--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-07-24 15:53:20 UTC ---
(In reply to comment #1)
> (In reply to comment #0)
> > program abs
> >   print *, abs(-1)
> > end program

> Back to your example, and quoting from the Fortran standard (cf.
> http://gcc.gnu.org/wiki/GFortranStandards; F2008, Section 16.2):
> "Program units, common blocks, external procedures, entities with binding
> labels, external input/output units, pending data transfer operations, and
> images are global entities of a program. [...]"
> "The global identifier of an entity shall not be the same as the global
> identifier of any other entity."
> Here, "program abs" is a "program unit" and the function "abs" of "abs(-1)" is
> an "external procedure".

Actually, if you meant the intrinsic "abs" function, that the "abs" in
"abs(-1)" is not an "external procedure" and, thus, that "abs" is not a global
name. But a local identifier

"Identifiers of entities in the classes
 (1) [...] intrinsic procedures, [...]
are local identifiers."

Nonetheless, it is invalid as:

> As used in my example, the "abs" subroutine is a local
> identifier, which per 16.3.1 "shall not be the same as a global identifier
> used in that scope unless [...]" - thus, I used a different name, i.e "test".)

More information about the Gcc-bugs mailing list