Possible bug in optimization

Sergei Organov osv@javad.ru
Wed Feb 19 12:12:00 GMT 2003


Zack Weinberg <zack@codesourcery.com> writes:
> 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.

That's true, but there are two questions here though:

1. Are there any reasons why GCC doesn't define 'undefined behavior' to be the
   only useful behavior in this case (i.e., doesn't do what it did in earlier
   versions)? Speedup/simplification of alias analysis?

2. If there are sound reasons to keep current definition of 'undefined
   behavior' for this case, it would be great to be able to ask GCC to produce
   diagnostic. Is it already possible? How?

Thanks in advance.

-- 
Sergei.



More information about the Gcc-bugs mailing list