Fortran question
Lassi A.Tuura
lassi.tuura@cern.ch
Tue Aug 3 06:04:00 GMT 2004
> With IMA, I've discovered that one of the Fortran SPEC benchmarks
> (fma3d)
> has a named common block that is different sizes in different source
> files, in
> violation of both the f77 and f90 standards. However, the fact that
> this program
> normally works, presumably in a lot of different environments, when it
> would
> be easy to detect the error at linktime, suggests that maybe it is
> used a fair
> amount in existing code, and maybe it would be a good idea for the
> compiler
> to accept it. What do the Fortran experts think? Thanks.
I'm not a FORTRAN programmer, but I can tell what the millions of lines
we have here expect :-) The linker should pick the largest size for the
common.
At least in our F77 code it's a widely used idiom. Some programmers
just declare the common to a small size, such as one, assuming it's
declared to the right size somewhere else. For the same reason I've
never heard that compiler-generated array bounds checking was used for
our code. It's useless when all the arrays are declared to
ridiculously small sizes, and then one object file somewhere changes
all the bounds. Typically that object file isn't even part of the
libraries that use the common, but in user code. In fact, the actual
common might get picked only at run-time by the dynamic linker :-)
(That latter is not very typical for F77 programs, but more usual for
current C++ programs using legacy F77 libraries. And no, dynamic
linker doesn't need to pick the largest common, it should pick the
first definition and ignore all the others, no matter which library
they come from. Sort of like template static data in C++.)
Lassi
--
I would therefore like to posit that computing's central
challenge 'How not to make a mess of it,' has *not* been
met. --Edsger Dijkstra
More information about the Gcc
mailing list