Possible bug in optimization

Zack Weinberg zack@codesourcery.com
Sat Feb 15 03:27:00 GMT 2003


Chris Croswhite <ccroswhite@get2chip.com> writes:

> Here is a simple prog that I think might illustrate a bug in gcc-3.2.1/2
> optimization:

'Fraid not.

> #include <stdio.h>
> int main(int argc, char **argv)
> {
>   long long val = 0x4000000000000001;
>   (((int*) &val)[1]) &= 0x0;

This line causes undefined behavior.  GCC is allowed to reduce your
code to smoking rubble.

>   printf("%lld\n", val);
>   return 1;
> }

zw



More information about the Gcc-bugs mailing list