From owner-freebsd-current Sun Feb 9 6:24:18 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA39F37B401 for ; Sun, 9 Feb 2003 06:24:16 -0800 (PST) Received: from gw.nectar.cc (gw.nectar.cc [208.42.49.153]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49E1843FAF for ; Sun, 9 Feb 2003 06:24:13 -0800 (PST) (envelope-from nectar@celabo.org) Received: from opus.celabo.org (opus.celabo.org [10.0.1.111]) by gw.nectar.cc (Postfix) with ESMTP id DA15BA3; Sun, 9 Feb 2003 08:24:12 -0600 (CST) Received: by opus.celabo.org (Postfix, from userid 1001) id 4D8435965; Sun, 9 Feb 2003 08:22:01 -0600 (CST) Date: Sun, 9 Feb 2003 08:22:01 -0600 From: "Jacques A. Vidrine" To: Terry Lambert , David Schultz , Ray Kohler , freebsd-current@FreeBSD.ORG Subject: Re: Compiling with high optimization? Message-ID: <20030209142200.GH67612@opus.celabo.org> Mail-Followup-To: "Jacques A. Vidrine" , Terry Lambert , David Schultz , Ray Kohler , freebsd-current@FreeBSD.ORG References: <20030208173756.GA56030@arkadia.nv.cox.net> <20030208232724.GA20435@HAL9000.homeunix.com> <3E459BF3.BB3FC381@mindspring.com> <20030209002542.GA20812@HAL9000.homeunix.com> <3E45AD75.47C80368@mindspring.com> <20030209140357.GB67612@opus.celabo.org> <20030209141711.GA35708@falcon.midgard.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030209141711.GA35708@falcon.midgard.homeip.net> X-Url: http://www.celabo.org/ User-Agent: Mutt/1.5.1i-ja.1 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Feb 09, 2003 at 03:17:12PM +0100, Erik Trulsson wrote: > On Sun, Feb 09, 2003 at 08:03:57AM -0600, Jacques A. Vidrine wrote: > > On Sat, Feb 08, 2003 at 05:23:01PM -0800, Terry Lambert wrote: > > > The compiler > > > didn't complain when he checked it before committing it because > > > optimization was off by default; it should have complained, e.g.: > > ^^^^^^^^^^^^ > > Is that really what you meant? I don't believe it has anything to > > do with optimization; rather, it is to do with lack of `warning' > > flags. For example, if you build libc with WARNS=5 (so as to get the > > `-Wuninitialized' flag), then you get this warning. > > > > > "x.c:9:warning: `foo' might be used uninitialized in this function" > > Some warnings are not generated unless you compile with optimization > on. The reason for this is that to generate some of the warnings (for > example about uninitialized variables) you need to do some dataflow > analysis and gcc only does this when optimizing. > > Take for example this little program: > > #include > int main(void) > { > int a; > printf("%d\n",a); > return 0; > } > > When compiled using 'gcc -O0 -Wall' no warnings are generated. When > compiled with 'gcc -O1 -Wall' you get a warning that 'a' might be used > uninitalized. (This is the case for gcc 2.95.x at least. I believe the > situation is the same with gcc 3.x) Ah, I see. Yes, it is the case with gcc 3.x. cc1: warning: -Wuninitialized is not supported without -O I don't think I ever knew that. I should have tried it before posting, but the comment that the problem was that `optimization was off by default' threw me --- it is ON by default. Cheers, -- Jacques A. Vidrine http://www.celabo.org/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message