public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/29227] New: gcc sometimes doesn't recognize uninitialized variables
@ 2006-09-25 22:40 debian-gcc at lists dot debian dot org
2006-09-25 22:44 ` [Bug c/29227] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2006-09-25 22:40 UTC (permalink / raw)
To: gcc-bugs
[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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/29227] gcc sometimes doesn't recognize uninitialized variables
2006-09-25 22:40 [Bug c/29227] New: gcc sometimes doesn't recognize uninitialized variables debian-gcc at lists dot debian dot org
@ 2006-09-25 22:44 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-25 22:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-09-25 22:44 -------
This is an old problem really.
This is a dup of bug 19430.
*** This bug has been marked as a duplicate of 19430 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29227
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-09-25 22:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-25 22:40 [Bug c/29227] New: gcc sometimes doesn't recognize uninitialized variables debian-gcc at lists dot debian dot org
2006-09-25 22:44 ` [Bug c/29227] " pinskia at gcc dot gnu dot org
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).