GCC 2.95 and floating point precision
Toon Moene
toon@moene.indiv.nluug.nl
Tue Aug 31 23:20:00 GMT 1999
Stephen L Moshier wrote:
>
> GCC-2.95 is more sensitive than any previous GCC version has been
> to the floating point pointer aliasing feature-bug of ANSI C.
:-)
> The program you referenced contains code that is not valid ANSI C,
> such as the following:
>
> long double ChopVar;
> *Lo = *((unsigned long int *) &ChopVar);
> *Hi = (*(((unsigned long int *) &ChopVar) + 1)) & ~2147483648U;
>
> You may not do this any more. It is verboten. You are supposed to use
> a union containing the float and the int together.
Phew - it's questionable whether I would ever have found that. Thanks,
Stephen ...
Using either -O1 or -O2 -fno-strict-aliasing delivers the same result.
Far be it from me to proclaim that it's the _correct_ result - I only
know the 20 leading digits of pi (and that's including the `3').
HTH,
--
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
GNU Fortran: http://world.std.com/~burley/g77.html
More information about the Gcc
mailing list