From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 23 10:00:15 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8C4D816A40F for ; Sat, 23 Dec 2006 10:00:15 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from ch-smtp01.sth.basefarm.net (ch-smtp01.sth.basefarm.net [80.76.149.212]) by mx1.freebsd.org (Postfix) with ESMTP id E047113C442 for ; Sat, 23 Dec 2006 10:00:10 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from c83-253-29-241.bredband.comhem.se ([83.253.29.241]:55887 helo=falcon.midgard.homeip.net) by ch-smtp01.sth.basefarm.net with smtp (Exim 4.63) (envelope-from ) id 1Gy3RC-0000S5-5s for freebsd-hackers@freebsd.org; Sat, 23 Dec 2006 10:45:07 +0100 Received: (qmail 25603 invoked from network); 23 Dec 2006 10:45:04 +0100 Received: from owl.midgard.homeip.net (10.1.5.7) by falcon.midgard.homeip.net with SMTP; 23 Dec 2006 10:45:04 +0100 Received: (qmail 5574 invoked by uid 1001); 23 Dec 2006 10:45:04 +0100 Date: Sat, 23 Dec 2006 10:45:04 +0100 From: Erik Trulsson To: "Joseph J. Damato" Message-ID: <20061223094504.GA5538@owl.midgard.homeip.net> Mail-Followup-To: "Joseph J. Damato" , Uwe Doering , freebsd-hackers@freebsd.org, Garrett Cooper 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2288.69.125.236.143.1166859495.squirrel@69.125.236.143> User-Agent: Mutt/1.5.13 (2006-08-11) X-ACL-Warn: Too high rate of unknown addresses received from you X-Scan-Result: No virus found in message 1Gy3RC-0000S5-5s. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1Gy3RC-0000S5-5s 39277ddce0603f6b75ae47702228ee0f Cc: freebsd-hackers@freebsd.org, Garrett Cooper , Uwe Doering Subject: Re: Properly controlling CFLAGS/CXXFLAGS X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Dec 2006 10:00:15 -0000 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. -- Erik Trulsson ertr1013@student.uu.se