Bug 29227 - gcc sometimes doesn't recognize uninitialized variables
Summary: gcc sometimes doesn't recognize uninitialized variables
Status: RESOLVED DUPLICATE of bug 19430
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-25 22:40 UTC by Debian GCC Maintainers
Modified: 2006-09-25 22:44 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2006-09-25 22:40:07 UTC
[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;
}
Comment 1 Andrew Pinski 2006-09-25 22:44:12 UTC
This is an old problem really.
This is a dup of bug 19430.

*** This bug has been marked as a duplicate of 19430 ***