fails to compile the valid code
Richard E Maine
Richard.Maine@nasa.gov
Wed Nov 23 18:51:00 GMT 2005
On Nov 22, 2005, at 4:52 PM, Uttam Pawar wrote:
> gfortran fails to compile the valid code (which has structure
> constructor and generic name)
As others have noted, this is not valid f95 code. I base that on the
standard, rather than on how various compilers happen to behave. The
xlf message cited from xlf in a later posting gives the relevant
restriction of the standard. In general, you usually can't use the same
name for two different things in the same scope. (The actual statement
of the conditions in the standard goes on for most of a page, but it
boils down to that as the simple version, with some exceptions). There
are a few exceptions, but not many. As the clf messages mentions, one
of the exceptions is that you can use the same name for a generic and
specific, but that's not what this code does.
F2003 adds another exception, which *IS* what this code does. In f2003,
a generic can have the same name as a derived type, essentially
providing a way to override or extend structure constructors (since
function references look an awful lot like structure constructors). So
perhaps you might want to consider this as one of your f2003 feature
test cases, but it isn't valid f95 code.
--
Richard Maine | Good judgment comes from experience;
Richard.Maine@nasa.gov | experience comes from bad judgment.
| -- Mark Twain
More information about the Fortran
mailing list