This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/55060] New: False un-initialized variable warnings
- From: "shenhan at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Oct 2012 17:44:35 +0000
- Subject: [Bug c/55060] New: False un-initialized variable warnings
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060
Bug #: 55060
Summary: False un-initialized variable warnings
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: shenhan@google.com
Compiler version - trunk @ 192770
Compilation option - -c -O2 -Wall
Source -
static void a(int *i) { }
static void b(int p) { }
int main(int argc, char *argv[]) {
int i;
a(&i);
b(i);
return 0;
}
Compilation output -
/home/shenhan/test.c: In function âmainâ:
/home/shenhan/test.c:7:4: warning: âiâ is used uninitialized in this function
[-Wuninitialized]
b(i);
^
A quick diagnose by David (Xingliang) Li is copied below -
"The early uninitialized variable warning happens before inlining phase. Before
4.7, compiler does not warn this because the call to a(&i) which may initialize
'i' (the analysis is only intra-procedural).
In 4.7 (and above), the SRA optimization pass which happens before the analysis
is smart enough to replace the call to 'a' into a clone of 'a' which takes no
argument. However the second access to 'i' still remains, thus the warning."