[Bug fortran/58270] Wrong code while accessing array elements in a global structure

strasbur at chkw386 dot ch.pwr.wroc.pl gcc-bugzilla@gcc.gnu.org
Mon Sep 2 16:32:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58270

--- Comment #16 from Krzysztof Strasburger <strasbur at chkw386 dot ch.pwr.wroc.pl> ---
Dear Dominique,
I cannot agree with you. You are interpreting the code that may access the
array beyond declared bounds as invalid, which is simply not true.
As you pointed it out before, unnamed common block may be declared larger
elsewhere, so writing the dmem array beyond its first element may be a design
decision and therefore may be perfectly legal. The compiler has no clue about
real size of unnamed common while compiling buggy.f and bounds checking is
optional.
I would also like to point it out that interpreting things this way you do, you
exclude some older FORTRAN77 software (for example: quantum chemistry GAMESS),
in which the lack of dynamic memory allocation was overcome using the trick we
are discussing here (mixing with C was needed). BTW, change the size of dmem to
2 in buggy.f and things start to work correctly, although "out of bounds"
memory accesses still do happen. The problem occurs only if dmem is of size 1.
Of course you (developers) may decide to ignore this problem anyway, so if you
do so, feel free to close this bug. I'm not going to reopen it again, because
I'm out of arguments. I'm also not competent enough to tamper with the
compiler.



More information about the Gcc-bugs mailing list