RE: Missing warning about uninitialized variable.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I still haven't seen anybody comment on why that warning isn't displayed
with the latest GCC versions, no matter how many extra parameters you give
it?

I cannot - no matter how I try - make GCC print a warning for the relatively
simple case:

void func(void) {
   int i;
   if(some-condition)
      i = 1;
   use(i);
}

If I compile this with "-O -Wall -Wuninitialized" I still get _no_ warning.

/Mikael

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of John Love-Jensen
Sent: den 29 november 2007 22:30
To: J.C. Pizarro; MSX to GCC
Subject: Re: Missing warning about uninitialized variable.

Hi J.C.,

In your ishootyou.c, if your objective is to have the compiler display the
warning, ala...

gcc -O -Wuninitialized -lm -Wall ishootyou.c -o ishootyou

ishootyou.c:12: warning: 'uninitialized_var_gurka' may be used uninitialized
in this function

...how come you are not enabling the warning, as I've done above?

Or even more so, as indicated by the comment in the code, treating it as an
error?

gcc -Werror -O -Wuninitialized -lm -Wall ishootyou.c -o ishootyou

On my version of GCC, I realize that -Wall enables -Wuninitialized ... but
ONLY if optimizations are enabled.  Which has already been mentioned by
someone else in this discussion thread.

Sincerely,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux