public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55060] New: False un-initialized variable warnings
@ 2012-10-24 17:44 shenhan at google dot com
  2012-10-24 17:50 ` [Bug tree-optimization/55060] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: shenhan at google dot com @ 2012-10-24 17:44 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-25 23:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-24 17:44 [Bug c/55060] New: False un-initialized variable warnings shenhan at google dot com
2012-10-24 17:50 ` [Bug tree-optimization/55060] " pinskia at gcc dot gnu.org
2012-10-24 17:56 ` shenhan at google dot com
2012-10-24 19:19 ` manu at gcc dot gnu.org
2012-10-24 19:21 ` manu at gcc dot gnu.org
2012-10-25 11:22 ` rguenth at gcc dot gnu.org
2021-03-25 23:19 ` [Bug tree-optimization/55060] False un-initialized variable warnings (fixed, add testcase to testsuite) msebor at gcc dot gnu.org
2021-03-25 23:24 ` cvs-commit at gcc dot gnu.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).