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 <stdio.h>
> 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 <[EMAIL PROTECTED]>          http://www.celabo.org/
NTT/Verio SME          .     FreeBSD UNIX     .       Heimdal Kerberos
[EMAIL PROTECTED]     .  [EMAIL PROTECTED]  .          [EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to