public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/29227] New: gcc sometimes doesn't recognize uninitialized variables Date: Mon, 25 Sep 2006 22:40:00 -0000 [thread overview] Message-ID: <bug-29227-5724@http.gcc.gnu.org/bugzilla/> (raw) [forwarded from http://bugs.debian.org/386174] bug submitter writes (4.1 and trunk): In the following program, gcc fails to recognize that "n" is uninitialized, unless the "sscanf" line is commented out. I expected no change at all, since sscanf() is called after foo(). Since the compiler is responsible for guaranteeing that the program runs as if this order is true (even if it is not), I expect it to be aware of the initialized state of the variables. gcc-4.1 -std=gnu99 -W -Wall -O3 -g ss.c -o ss ss.c: In function 'main': ss.c:6: warning: 'n' is used uninitialized in this function gcc-4.1 -DSS -std=gnu99 -W -Wall -O3 -g ss.c -o ss [no warning] #define _GNU_SOURCE #include <stdio.h> static void foo(size_t *n) { printf("%d\n", *n); } int main() { size_t n; foo(&n); #ifdef SS sscanf("1234", "%zd", &n); #endif return 0; } -- Summary: gcc sometimes doesn't recognize uninitialized variables Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: debian-gcc at lists dot debian dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29227
next reply other threads:[~2006-09-25 22:40 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-09-25 22:40 debian-gcc at lists dot debian dot org [this message] 2006-09-25 22:44 ` [Bug c/29227] " pinskia at gcc dot gnu dot org
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=bug-29227-5724@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).