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


Zack Weinberg <zack at codesourcery dot com> writes:
> Chris Croswhite <ccroswhite at get2chip dot 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.


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