Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Dec 2006 02:38:15 -0500 (EST)
From:      "Joseph J. Damato" <jdamato@andrew.cmu.edu>
To:        "Uwe Doering" <gemini@geminix.org>
Cc:        freebsd-hackers@freebsd.org, Garrett Cooper <youshi10@u.washington.edu>
Subject:   Re: Properly controlling CFLAGS/CXXFLAGS
Message-ID:  <2288.69.125.236.143.1166859495.squirrel@69.125.236.143>
In-Reply-To: <458C7DC4.1080304@geminix.org>
References:  <200612220850.kBM8oDD0037287@lurza.secnetix.de> <458C1BCB.6040907@u.washington.edu> <458C7DC4.1080304@geminix.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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




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