Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 08 Feb 2003 17:23:01 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        David Schultz <dschultz@uclink.berkeley.edu>
Cc:        Ray Kohler <ataraxia@cox.net>, freebsd-current@FreeBSD.ORG
Subject:   Re: Compiling with high optimization?
Message-ID:  <3E45AD75.47C80368@mindspring.com>
References:  <20030208173756.GA56030@arkadia.nv.cox.net> <20030208232724.GA20435@HAL9000.homeunix.com> <3E459BF3.BB3FC381@mindspring.com> <20030209002542.GA20812@HAL9000.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
David Schultz wrote:
> Thus spake Terry Lambert <tlambert2@mindspring.com>:
> > Actually, failure to use optimization suppresses some compilation
> > warnings, particularly those which normally print from using some
> > variables without initializing them.
> 
> I think you're thinking of dataflow analysis, which I believe gcc
> does with -O and higher optimization levels.  So unless you're
> using -O0, I would expect that you'd get all the warnings you
> want.

See the thread "Re: tmpfile breakage on setuid executables".

Kris accidently introduced a bug that had to do with whether or
not a variable was used before it was initialized.  The compiler
didn't complain when he checked it before committing it because
optimization was off by default; it should have complained, e.g.:

    "x.c:9:warning: `foo' might be used uninitialized in this function"



> > There are a number of places, particularly on non-i386 platforms,
> > where optimization actually doesn't work.  I think that's why it
> > was turned off for the libc compilation, and why the bug crept in.
> >
> > It's probably useful to compile world with optimization occasionally,
> > to make compilation-time detectable bugs like that to show up, but, as
> > you point out, it'd probably be a *bad* idea to actually use the
> > resulting code, at least until after the next GCC import, which will
> > supposedly fix the Alpha optimizer.
> 
> Yes, the possibility of being bitten by compiler bugs is certainly
> higher with higher optimization levels.  Alpha with -O2 seems to
> have been broken for years, and I have seen strange things happen
> on IA64 as well.  But the i386 code generators have received much
> wider testing and debugging, so there is somewhat less danger there.

Yes.  I just wanted to point out that what's probably a good idea
for catching coding errors like uninitialized variables is definitely
not a good idea for distributing code for people to run.  I wasn't
really sure why he was asking, so I tried to look at it from both
angles.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E45AD75.47C80368>