Optimizer bug in 2.95.1

Alexandre Oliva oliva@lsd.ic.unicamp.br
Thu Sep 30 19:57:00 GMT 1999

On Sep 15, 1999, Greg Wolodkin <greg@mathworks.com> wrote:

> Hope this is useful in finding and fixing this bug -- let me know
> if I can do more.

You've fallen victim of the -fstrict-aliasing option, enabled by
default in gcc 2.95.  Your code invokes undefined behavior, according
to the ANSI/ISO C Standard, because it accesses a memory area of one
type (namely, double) with a pointer to a different type (namely,
unsigned long).

gcc will assume the pointer to unsigned long can't refer to a double
unless you compile with -fno-strict-aliasing or, instead of type
double, the variable has type `union { double x; unsigned long y; }'.

Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
** I may forward mail about projects to mailing lists; please use them

More information about the Gcc-bugs mailing list