This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Possible bug in optimization
- From: "Chris Croswhite" <ccroswhite at get2chip dot com>
- To: <zack at codesourcery dot com>
- Cc: <ccroswhite at get2chip dot com>, <gcc-bugs at gcc dot gnu dot org>
- Date: Tue, 18 Feb 2003 12:27:57 -0800 (PST)
- Subject: Re: Possible bug in optimization
- References: <87y94ifckn.fsf@egil.codesourcery.com>
- Reply-to: ccroswhite at get2chip dot com
How is this casting & masking undefined in O but -g works OKAY? Also, why
does 2.95.x treat this as expected? Also, Sun, HP and Intel compilers treat
this as expected? What am I not understanding about c/c++ standard?
TIA,
Chris
Zack Weinberg said:
> 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