Undocumented (probably dangerous) gfortran extension

Martin Reinecke martin@MPA-Garching.MPG.DE
Wed Mar 29 12:11:00 GMT 2006


Hi,

I noticed that gfortran compiles the following code without warning.

program test
implicit none
integer foo
common /bar/ foo
data foo /0/
end

This is not valid Fortran, since members of common blocks may only be
initialized by BLOCK DATA statements. g77 and the Intel compiler also
accept this code, but all other Fortran compilers I tried (Fujitsu, NAG,
xlf90) reject it.
If "-std=f90" is passed to gfortran, it rejects the code as well.
So this "feature" can be interpreted as an extension, but I didn't find
it in the gfortran documentation.

In my opinion this extension is very dangerous, since one could in principle
write
   data /foo/ 0
in a.f90, and
   data /foo/ 1
in b.f90, and the compiler would most likely have no chance to detect this
problem, leading to undefined behaviour.

Is this extension really needed? If so, it should probably be documented.

Cheers,
   Martin



More information about the Fortran mailing list