Re: Properly controlling CFLAGS/CXXFLAGS
- From: Erik Trulsson <ertr1013@xxxxxxxxxxxxx>
- Date: Sat, 23 Dec 2006 10:45:04 +0100
On Sat, Dec 23, 2006 at 02:38:15AM -0500, Joseph J. Damato wrote:
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."
Well. no, the code might just have plain old bugs.
Any code that requires -fno-strict-aliasing is incorrect. (Or it might
indicate a bug in the compiler, but that is far less common.)
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.
The code might look right at first glance, but if it breaks with
-fstrict-aliasing then the code is almost certainly wrong.
It is very common that buggy code seems to work fine when compiled
with a low optimization level, but when compiled with higher optimization
the bugs are exposed.
In situations like this, the flag is useful.
Yes, -fno-strict-aliasing is indeed useful to get some old, buggy code (as
well as some new, buggy code) to work until the code in question can be
fixed.
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@xxxxxxxxxxxxx
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- References:
- Re: Properly controlling CFLAGS/CXXFLAGS
- From: Oliver Fromme
- Re: Properly controlling CFLAGS/CXXFLAGS
- From: Garrett Cooper
- Re: Properly controlling CFLAGS/CXXFLAGS
- From: Uwe Doering
- Re: Properly controlling CFLAGS/CXXFLAGS
- From: Joseph J. Damato
- Re: Properly controlling CFLAGS/CXXFLAGS
- Prev by Date: Re: Properly controlling CFLAGS/CXXFLAGS
- Next by Date: Re: Locking fundamentals
- Previous by thread: Re: Properly controlling CFLAGS/CXXFLAGS
- Index(es):
Relevant Pages
|
|