Properly controlling CFLAGS/CXXFLAGS
Joseph J. Damato
jdamato at andrew.cmu.edu
Sat Dec 23 00:17:05 PST 2006
> Garrett Cooper wrote:
>
> With '-O2' and better, '-fstrict-aliasing' is the default in newer
> versions of GCC, AFAIK, but people tend to switch it off because it
> apparently breaks too many software packages. Or at least those whose
> code base dates back to times where '-fno-strict-aliasing' was the default
> and people got away with certain nasty coding hacks that no longer work
> with '-fstrict-aliasing'.
>
Well, -fno-strict-aliasing is pretty useful, especially if you want to do things with floating point. Not all code which requires -fno-strict-aliasing has "nasty coding hacks."
As GCC says, the results are undefined when the flag is not passed. I have personally seen code that "looks" right but which results in very odd behavior with -O2, but works fine with any other optimization level.
In situations like this, the flag is useful.
Joe Damato
More information about the freebsd-hackers
mailing list