Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Dec 2006 10:45:04 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        "Joseph J. Damato" <jdamato@andrew.cmu.edu>
Cc:        freebsd-hackers@freebsd.org, Garrett Cooper <youshi10@u.washington.edu>, Uwe Doering <gemini@geminix.org>
Subject:   Re: Properly controlling CFLAGS/CXXFLAGS
Message-ID:  <20061223094504.GA5538@owl.midgard.homeip.net>
In-Reply-To: <2288.69.125.236.143.1166859495.squirrel@69.125.236.143>
References:  <200612220850.kBM8oDD0037287@lurza.secnetix.de> <458C1BCB.6040907@u.washington.edu> <458C7DC4.1080304@geminix.org> <2288.69.125.236.143.1166859495.squirrel@69.125.236.143>

next in thread | previous in thread | raw e-mail | index | archive | help
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@student.uu.se



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061223094504.GA5538>