c99/c++ localised variable definition

Ulrich Spoerlein q at uni.de
Mon Jan 31 10:42:27 PST 2005


On Mon, 31.01.2005 at 17:04:17 +0000, Paul Richards wrote:
> > > % cc -Wall -std=c99 test.c && ./a.out
> > > 1
> > gcc should be throwing an uninitialised warning here.
> 
> With the right warns it does :-)
> 
> cc -Wall -std=c99 -O -Wuninitialized test.c
> test.c
> test.c: In function `main':
> test.c:7: warning: 'i' might be used uninitialized in this function

Grrr, I knew I should've read the man page. I guess you can't expect to
get _all_ warnings when specifying -Wall
*sigh*

% cc -std=c99 -O -pedantic -Wall -Wshadow -Wuninitialized test.c
test.c: In function `main':
test.c:8: warning: declaration of 'i' shadows a previous local
test.c:7: warning: shadowed declaration is here
test.c:7: warning: 'i' might be used uninitialized in this function

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44				Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn."
didn't you understand?


More information about the freebsd-arch mailing list