This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/55060] New: False un-initialized variable warnings


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."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]