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: -O2 bug in gcc 3.2, 3.3 and 3.4 with 64 bit integers on x86


Aha, I see the problem now, I'll go fix my code. Not entirely obvious to 
a novice like me...

Perhaps GCC should not accept code that will result in undefined 
behaviour (that is with -fstrict-aliasing, -Wstrict-aliasing should be 
automatically enabled and any such warnings should be considered 
errors)? I think the current behaviour is a bit dangerous, since the 
code works in previous versions of GCC, and with other compilers, and 
that the current compiler does accept the code although it knows that 
it will probably do wrong.

/Anders Torger

On Tuesday 09 November 2004 17.26, Andreas Schwab wrote:
> Anders Torger <torger@ludd.luth.se> writes:
> > Compiler makes same mistake
>
> Fix your code.
>
> > the only difference is the warning
>
> Which is the whole point.  Your example is violating the strict
> aliasing rules and thus invoking undefined behaviour.
>
> http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Optimize-Options.html#ind
>ex-fstrict_002daliasing-422
>
> Andreas.


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