From: Mikael Vidstedt <mikael.vidstedt@bea.com>
To: gcc-help@gcc.gnu.org
Subject: Missing warning about uninitialized variable
Date: Thu, 29 Nov 2007 15:49:00 -0000 [thread overview]
Message-ID: <1196347151.19661.20.camel@cochrane.jrpg.bea.com> (raw)
The following program may make use of an uninitialized variable (gurka):
int
main(int argc, char* argv[])
{
int gurka;
if(argc == 10) {
gurka = 3;
}
// gurka isn't necessarily initialized here...
printf("%d\n", gurka);
return 0;
}
GCC 4.0 will give a warning when this program is compiled with "-O
-Wall". GCC 4.1 and 4.2 do not give that warning. I haven't had the
possibility to try GCC 4.3.
What say ye?
Thanks,
Mikael
# gcc-4.0 --version
gcc-4.0 (GCC) 4.0.4 20060904 (prerelease) (Debian 4.0.3-7)
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-4.0 -O -Wall -o foo foo.c
foo.c: In function 'main':
foo.c:6: warning: 'gurka' may be used uninitialized in this function
#
# gcc-4.1 --version
gcc-4.1 (GCC) 4.1.3 20071019 (prerelease) (Debian 4.1.2-17)
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-4.1 -O -Wall -o foo foo.c
#
# gcc-4.2 --version
gcc-4.2 (GCC) 4.2.3 20071014 (prerelease) (Debian 4.2.2-3)
Copyright (C) 2007 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-4.2 -O -Wall -o foo foo.c
#
next reply other threads:[~2007-11-29 14:44 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 15:49 Mikael Vidstedt [this message]
2007-11-30 16:31 ` Ian Lance Taylor
2007-11-29 16:01 J.C. Pizarro
2007-11-29 16:18 ` eschenb
2007-11-29 16:32 ` J.C. Pizarro
2007-11-29 16:41 ` eschenb
2007-11-29 16:45 ` J.C. Pizarro
2007-11-29 16:48 ` Tom St Denis
2007-11-29 16:57 ` J.C. Pizarro
2007-11-29 16:58 ` Tom St Denis
2007-11-29 18:11 ` J.C. Pizarro
2007-11-29 18:16 ` Tom St Denis
2007-11-29 18:20 ` Mikael Vidstedt
2007-11-29 18:30 ` Tom St Denis
2007-11-29 18:31 ` Mikael Vidstedt
2007-11-29 21:12 ` J.C. Pizarro
2007-11-29 21:10 ` J.C. Pizarro
2007-11-29 21:30 ` J.C. Pizarro
2007-11-29 21:42 ` John Love-Jensen
2007-11-29 21:42 ` Mikael Vidstedt
2007-11-29 22:12 ` Tony Wetmore
2007-11-29 22:03 ` J.C. Pizarro
2007-11-29 17:48 ` John Love-Jensen
2007-11-29 18:02 ` J.C. Pizarro
2007-11-29 16:51 ` J.C. Pizarro
2007-11-29 18:18 ` Sven Eschenberg
2007-11-29 18:22 ` Tom St Denis
2007-11-29 18:57 ` Sven Eschenberg
[not found] ` <C3743DA6.273A8%eljay@adobe.com>
2007-11-29 16:22 ` J.C. Pizarro
2009-11-25 10:09 David Sveningsson
2009-11-27 14:29 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1196347151.19661.20.camel@cochrane.jrpg.bea.com \
--to=mikael.vidstedt@bea.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).