public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -Wall not detecting uninitialized variables
@ 2011-09-07 16:34 sudhakar govindavajhala
  2011-09-07 16:37 ` Andrew Haley
  0 siblings, 1 reply; 4+ messages in thread
From: sudhakar govindavajhala @ 2011-09-07 16:34 UTC (permalink / raw)
  To: gcc-help

Hello all,

How come -Wall is not detecting unitialized variables?

Thanks,
Sudhakar

$cat test.c
#include <stdio.h>

int main() {
        int i;
        printf(" hi sud %d \n", i);
        return 0;

}

$gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$gcc -Wall test.c
$g++ -Wall test.c
$

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -Wall not detecting uninitialized variables
  2011-09-07 16:34 -Wall not detecting uninitialized variables sudhakar govindavajhala
@ 2011-09-07 16:37 ` Andrew Haley
  2011-09-07 16:44   ` Axel Freyn
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Haley @ 2011-09-07 16:37 UTC (permalink / raw)
  To: gcc-help

On 09/07/2011 05:34 PM, sudhakar govindavajhala wrote:
> #include <stdio.h>
> 
> int main() {
>         int i;
>         printf(" hi sud %d \n", i);
>         return 0;
> 
> }

zebedee:~ $ gcc --version
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

zebedee:~ $ gcc -Wall t.c
t.c: In function 'main':
t.c:5:15: warning: 'i' is used uninitialized in this function

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -Wall not detecting uninitialized variables
  2011-09-07 16:37 ` Andrew Haley
@ 2011-09-07 16:44   ` Axel Freyn
  2011-09-08  2:48     ` sudhakar govindavajhala
  0 siblings, 1 reply; 4+ messages in thread
From: Axel Freyn @ 2011-09-07 16:44 UTC (permalink / raw)
  To: gcc-help

On Wed, Sep 07, 2011 at 05:36:50PM +0100, Andrew Haley wrote:
> On 09/07/2011 05:34 PM, sudhakar govindavajhala wrote:
> > #include <stdio.h>
> > 
> > int main() {
> >         int i;
> >         printf(" hi sud %d \n", i);
> >         return 0;
> > 
> > }
> 
> zebedee:~ $ gcc --version
> gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
> 
> zebedee:~ $ gcc -Wall t.c
> t.c: In function 'main':
> t.c:5:15: warning: 'i' is used uninitialized in this function

gcc 4.1 warns if optimization is activated:
Jupiter:~ $ gcc-4.1 -Wall -O test.c
test.c: In function ‘main’:
test.c:5: warning: ‘i’ is used uninitialized in this function

Jupiter:~ $ gcc-4.1 --version
gcc-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-29)

Axel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -Wall not detecting uninitialized variables
  2011-09-07 16:44   ` Axel Freyn
@ 2011-09-08  2:48     ` sudhakar govindavajhala
  0 siblings, 0 replies; 4+ messages in thread
From: sudhakar govindavajhala @ 2011-09-08  2:48 UTC (permalink / raw)
  To: gcc-help

thank you.

On Wed, Sep 7, 2011 at 12:44 PM, Axel Freyn <axel-freyn@gmx.de> wrote:
> On Wed, Sep 07, 2011 at 05:36:50PM +0100, Andrew Haley wrote:
>> On 09/07/2011 05:34 PM, sudhakar govindavajhala wrote:
>> > #include <stdio.h>
>> >
>> > int main() {
>> >         int i;
>> >         printf(" hi sud %d \n", i);
>> >         return 0;
>> >
>> > }
>>
>> zebedee:~ $ gcc --version
>> gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
>>
>> zebedee:~ $ gcc -Wall t.c
>> t.c: In function 'main':
>> t.c:5:15: warning: 'i' is used uninitialized in this function
>
> gcc 4.1 warns if optimization is activated:
> Jupiter:~ $ gcc-4.1 -Wall -O test.c
> test.c: In function ‘main’:
> test.c:5: warning: ‘i’ is used uninitialized in this function
>
> Jupiter:~ $ gcc-4.1 --version
> gcc-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-29)
>
> Axel
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-08  2:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-07 16:34 -Wall not detecting uninitialized variables sudhakar govindavajhala
2011-09-07 16:37 ` Andrew Haley
2011-09-07 16:44   ` Axel Freyn
2011-09-08  2:48     ` sudhakar govindavajhala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).