stick addressable constants into the constant pool

Toon Moene toon@moene.indiv.nluug.nl
Sat Jul 31 19:36:00 GMT 2004


Richard Henderson wrote:

> This did show up two testsuite bugs, which wrote to arguments that
> were given as constants.  Which now gives a SEGV, since Linux puts
> the constant pool in read-only memory.  I guess we'll have to see
> how much trouble this give us with dusty decks...

Oh :-)

Thanks for fixing this.  Fortran programs trying this should crash hard 
on modern systems, to remind people they shouldn't do this (it *is* 
prohibited as per the Standard - at least as of Fortran 77, but probably 
Fortran 66).

You can't appreciate this unless you've spent weeks trying to find the 
following bug:

       PROGRAM BUGGY
       REAL X, Y
       READ, X, Y
       PRINT*, AVERAGE(X, Y, 2)
       READ, A, B
       PRINT*, AVERAGE(A, B, 2)
       END
       FUNCTION AVERAGE(A, B, N)
       AVERAGE = (A + B) / REAL(N)
       N = N + 1
       END

[ Yep, the original program was much larger (several thousands of lines)
   but you'll get the idea; the second "average" wasn't really the mean
   of A and B, but (A + B) / 3. - not to mention that all references to
   the litteral value 2 were changed (silently) to 3. ]

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/



More information about the Fortran mailing list