Consider the following code snippet:
$ cat testcase.c
int bar(int n) {
return n + 1;
}
int main(void) {
int a = bar(a);
int b, c, d;
b = bar(b);
(void) bar(c);
return bar(d);
}
Both a, b, c and d are used before they are initialized. However, we only get a
warning from d in gcc
3.3/3.4.
$ gcc -O2 -Wuninitialized testcase.c
testcase.c: In function `main':
testcase.c:8: warning: `d' might be used uninitialized in this function
Tested on:
gcc version 3.3 20030304 (Apple Computer, Inc. build 1640)
gcc version 3.4.2 [FreeBSD] 20040728
In gcc 2.95, we get a warning from b, c and d, but not a.
$ gcc -O2 -Wuninitialized testcase.c
testcase.c: In function `main':
testcase.c:8: warning: `b' might be used uninitialized in this function
testcase.c:8: warning: `c' might be used uninitialized in this function
testcase.c:8: warning: `d' might be used uninitialized in this function
Tested on:
gcc version 2.95.3 20010125 (prerelease) (OpenBSD)
--
Summary: Missing uninitialized warning
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: axel at zankasoftware dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19371