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

* [Bug tree-optimization/55060] False un-initialized variable warnings
  2012-10-24 17:44 [Bug c/55060] New: False un-initialized variable warnings shenhan at google dot com
@ 2012-10-24 17:50 ` pinskia at gcc dot gnu.org
  2012-10-24 17:56 ` shenhan at google dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-10-24 17:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
          Component|c                           |tree-optimization

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-10-24 17:50:05 UTC ---
Is it only because b does not use its arguments you are saying it is a false
un-initialized warning?


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

* [Bug tree-optimization/55060] False un-initialized variable warnings
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: shenhan at google dot com @ 2012-10-24 17:56 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

--- Comment #2 from Han Shen <shenhan at google dot com> 2012-10-24 17:55:40 UTC ---
Yeah, I think value of "i" is never used.


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

* [Bug tree-optimization/55060] False un-initialized variable warnings
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-24 19:19 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-24 19:18:51 UTC ---
This doesn't warn, so it seems there is something else going on apart from SRA.

static void b(int p) { }

int main(int argc, char *argv[]) {
  int i;
  b(i);
  return 0;
}

Moving a(&i) after b(i) also prevents the warning. 

Weird.


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

* [Bug tree-optimization/55060] False un-initialized variable warnings
  2012-10-24 17:44 [Bug c/55060] New: False un-initialized variable warnings shenhan at google dot com
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-24 19:21 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |24639

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-24 19:21:00 UTC ---
And the caret location is off-by-one. More weird.


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

* [Bug tree-optimization/55060] False un-initialized variable warnings
  2012-10-24 17:44 [Bug c/55060] New: False un-initialized variable warnings shenhan at google dot com
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-10-25 11:22 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-10-25
                 CC|                            |jamborm at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-10-25 11:22:40 UTC ---
At the point of the early uninit pass it sees:

main (int argc, char * * argv)
{
  int i;
  int D.1716;
  int i.0;

<bb 2>:
  a.isra.0 ();
  # VUSE <.MEM_3(D)>
  i.0_1 = i;
  b.isra.1 ();
  D.1716_2 = 0;
  # .MEM_4 = VDEF <.MEM_3(D)>
  i ={v} {CLOBBER};
  # VUSE <.MEM_4>
  return D.1716_2;

thus a read from the memory location 'i' which is uninitialized.  Dead code
elimination has not yet removed that read (i.0_1 is unused after all).

I'd say the literal presence of b (i) is considered a use of i in C-terms,
thus the warning is not really incorrect.

That IPA-SRA has this side-effect on the otherwise still unoptimized
body of main is bad - early uninit was put before early inlining for a reason
and now IPA-SRA defeats this ... can we make it more "IPA" like and
have an explicit local transform stage?


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

* [Bug tree-optimization/55060] False un-initialized variable warnings (fixed, add testcase to testsuite)
  2012-10-24 17:44 [Bug c/55060] New: False un-initialized variable warnings shenhan at google dot com
                   ` (4 preceding siblings ...)
  2012-10-25 11:22 ` rguenth at gcc dot gnu.org
@ 2021-03-25 23:19 ` msebor at gcc dot gnu.org
  2021-03-25 23:24 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-25 23:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org
   Target Milestone|---                         |5.0

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
Bisection points to r217125 as the fix.  Let me add the test and resolve it.

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

* [Bug tree-optimization/55060] False un-initialized variable warnings (fixed, add testcase to testsuite)
  2012-10-24 17:44 [Bug c/55060] New: False un-initialized variable warnings shenhan at google dot com
                   ` (5 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-25 23:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55060

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:e88ca9f42306e291d3cb2d34dd7f2b017a3c1e52

commit r11-7841-ge88ca9f42306e291d3cb2d34dd7f2b017a3c1e52
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu Mar 25 17:23:06 2021 -0600

    PR tree-optimization/55060 - False un-initialized variable warnings

    gcc/testsuite/ChangeLog:
            PR tree-optimization/55060
            * gcc.dg/uninit-pr55060.c: New.

^ 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).