This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: stick addressable constants into the constant pool
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Sat, 31 Jul 2004 21:47:00 +0200
- Subject: Re: stick addressable constants into the constant pool
- Organization: Moene Computational Physics, Maartensdijk, NL
- References: <20040730230653.GA27003@redhat.com>
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/