From: "J.C. Pizarro" <jcpiza@gmail.com>
To: "eschenb@informatik.uni-frankfurt.de"
<eschenb@informatik.uni-frankfurt.de>,
gcc-help@gcc.gnu.org
Subject: Re: Missing warning about uninitialized variable.
Date: Thu, 29 Nov 2007 16:32:00 -0000 [thread overview]
Message-ID: <998d0e4a0711290822n66f35d4fm4b35347b5b8dbc5d@mail.gmail.com> (raw)
In-Reply-To: <1945.85.180.167.9.1196352728.squirrel@webmail.informatik.uni-frankfurt.de>
On 2007/11/29, eschenb@informatik.uni-frankfurt.de
<eschenb@informatik.uni-frankfurt.de> wrote:
> Aside from the fact, that you obviously forgot a #include <stdio.h>,
> of course the output is random, if the variable stays uninitialized (./foo
> $seq 1 10) has an argc of 11, doesn't it?
>
> Regards
>
> -Sven
>
> > On 2007/11/29, Mikael Vidstedt <mikael.vidstedt@bea.com> wrote:
> >> 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
> >
> > It prints stochasticly random data too.
> >
> > gcc version 4.2.3 20071031 (prerelease)
> >
> > $ gcc -Wall -o foo foo.c
> > foo.c: In function 'main':
> > foo.c:11: warning: implicit declaration of function 'printf'
> > foo.c:11: warning: incompatible implicit declaration of built-in
> > function 'printf'
> > $ for i in $(seq 1 5); do ./foo $(seq 1 10) ; done
> > -1209020420
> > -1208291332
> > -1208422404
> > -1208803332
> > -1208823812
> > $
> >
> > J.C.Pizarro
It can be other bug more!
next prev parent reply other threads:[~2007-11-29 16:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 16:01 J.C. Pizarro
2007-11-29 16:18 ` eschenb
2007-11-29 16:32 ` J.C. Pizarro [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2009-11-25 10:09 David Sveningsson
2009-11-27 14:29 ` Ian Lance Taylor
2007-11-29 15:49 Mikael Vidstedt
2007-11-30 16:31 ` 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=998d0e4a0711290822n66f35d4fm4b35347b5b8dbc5d@mail.gmail.com \
--to=jcpiza@gmail.com \
--cc=eschenb@informatik.uni-frankfurt.de \
--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).