This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible bug in optimization


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]