public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
@ 2013-11-01 21:56 ` manu at gcc dot gnu.org
  2013-12-19 10:17 ` manu at gcc dot gnu.org
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: manu at gcc dot gnu.org @ 2013-11-01 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
This somehow got worse. Now we only warn with -O1 or -Os but not with -O2 or
-O3.
>From gcc-bugs-return-433296-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Nov 01 23:00:57 2013
Return-Path: <gcc-bugs-return-433296-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28588 invoked by alias); 1 Nov 2013 23:00:57 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 28446 invoked by uid 55); 1 Nov 2013 23:00:53 -0000
From: "emsr at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58708] string literal operator templates broken
Date: Fri, 01 Nov 2013 23:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: emsr at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58708-4-yM9sSAiXxp@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58708-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58708-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg00073.txt.bz2
Content-length: 729

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX708

--- Comment #9 from emsr at gcc dot gnu.org ---
Author: emsr
Date: Fri Nov  1 23:00:48 2013
New Revision: 204305

URL: http://gcc.gnu.org/viewcvs?rev 4305&root=gcc&view=rev
Log:

gcc/cp:

2013-11-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

    PR c++/58708
    * parser.c (make_string_pack): Discover non-const type and size
    of character and build parm pack with correct type and chars.


gcc/testsuite:

2013-11-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

    PR c++/58708
    * g++.dg/cpp1y/pr58708.C: New.



Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/pr58708.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
  2013-11-01 21:56 ` [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning manu at gcc dot gnu.org
@ 2013-12-19 10:17 ` manu at gcc dot gnu.org
  2013-12-19 10:40 ` philipp at marek dot priv.at
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: manu at gcc dot gnu.org @ 2013-12-19 10:17 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3182 bytes --]

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

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to philipp from comment #4)
> I have this or a very similar problem with debian amd64 4:4.8.2-1:
> 
> main.c: In function ‘main’:
> main.c:1231:23: error: ‘rv’ may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
>   return (rv_main >= 0 && rv_main < 0x70) ? rv_main : 1;

Can you attach a small, preprocessed testcase? See
http://gcc.gnu.org/bugs/minimize.html
>From gcc-bugs-return-438088-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Dec 19 10:39:41 2013
Return-Path: <gcc-bugs-return-438088-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17978 invoked by alias); 19 Dec 2013 10:39:40 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 17962 invoked by uid 48); 19 Dec 2013 10:39:37 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/59557] New: [4.8/4.9 Regression]
Date: Thu, 19 Dec 2013 10:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-59557-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg01743.txt.bz2
Content-length: 1041

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY557

            Bug ID: 59557
           Summary: [4.8/4.9 Regression]
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org

Created attachment 31479
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1479&actioníit
testcase

A libstdc++ change between r202388 and the 4.8.2 release broke Eigen.
Preprocessing the attached testcase with 4.8.2 and then compiling with -O0
gives

> ./a.out
Brute force distance = 0.00428018, calls = 10000
Segmentation fault

while preprocessing with 4.8.1 gets the correct

> ./a.out
Brute force distance = 0.00428018, calls = 10000
BVH distance         = 0.00428018, calls = 756


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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
  2013-11-01 21:56 ` [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning manu at gcc dot gnu.org
  2013-12-19 10:17 ` manu at gcc dot gnu.org
@ 2013-12-19 10:40 ` philipp at marek dot priv.at
  2013-12-19 10:51 ` manu at gcc dot gnu.org
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: philipp at marek dot priv.at @ 2013-12-19 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from philipp at marek dot priv.at ---
I'm trying to get a minimized file via creduce.

In case you have an experienced guess please look at src/main.c from
   github.com:ClusterLabs/booth.git
   44b06e6d3c9c81d287020fe017a05f1386ae5e6e


Thanks.


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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2013-12-19 10:40 ` philipp at marek dot priv.at
@ 2013-12-19 10:51 ` manu at gcc dot gnu.org
  2013-12-19 10:57 ` philipp at marek dot priv.at
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: manu at gcc dot gnu.org @ 2013-12-19 10:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to philipp from comment #6)
> I'm trying to get a minimized file via creduce.
> 
> In case you have an experienced guess please look at src/main.c from
>    github.com:ClusterLabs/booth.git
>    44b06e6d3c9c81d287020fe017a05f1386ae5e6e
> 
> 
> Thanks.

My guess is that it is exactly the same issue: inlining + variable coalescing.
The inlining part could be improved, but variable coalescing seems a harder
problem as long as we warn after coalescing (a unique name has to be chosen).
See comment #2.
>From gcc-bugs-return-438094-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Dec 19 10:56:45 2013
Return-Path: <gcc-bugs-return-438094-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 5198 invoked by alias); 19 Dec 2013 10:56:45 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 5177 invoked by uid 48); 19 Dec 2013 10:56:42 -0000
From: "philipp at marek dot priv.at" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
Date: Thu, 19 Dec 2013 10:56:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.4.1
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: philipp at marek dot priv.at
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-40635-4-JGaFyQtrdM@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-40635-4@http.gcc.gnu.org/bugzilla/>
References: <bug-40635-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg01749.txt.bz2
Content-length: 319

http://gcc.gnu.org/bugzilla/show_bug.cgi?id@635

--- Comment #8 from philipp at marek dot priv.at ---
I forgot to say that the uninitialized "rv" is in query_get_string_answer().

I've got a reduced main.c - but sadly there are still includes to other files,
so it won't help that much.

I'll attach it here anyway.


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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-12-19 10:51 ` manu at gcc dot gnu.org
@ 2013-12-19 10:57 ` philipp at marek dot priv.at
  2013-12-19 10:59 ` philipp at marek dot priv.at
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: philipp at marek dot priv.at @ 2013-12-19 10:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from philipp at marek dot priv.at ---
Created attachment 31480
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31480&action=edit
main.c

not much use because of includes.


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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2013-12-19 10:57 ` philipp at marek dot priv.at
@ 2013-12-19 10:59 ` philipp at marek dot priv.at
  2021-03-25 21:07 ` msebor at gcc dot gnu.org
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: philipp at marek dot priv.at @ 2013-12-19 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from philipp at marek dot priv.at ---
Well, I've found the culprit, so it's not that important to me anymore.

Getting a completely wrong code location is the problem - you don't know what
to fix, and have to do some kind of search.


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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2013-12-19 10:59 ` philipp at marek dot priv.at
@ 2021-03-25 21:07 ` msebor at gcc dot gnu.org
  2021-03-25 21:08 ` msebor at gcc dot gnu.org
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-25 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2019-02-24 00:00:00         |2021-3-25
      Known to fail|9.0                         |10.2.0, 11.0, 9.3.0

--- Comment #13 from Martin Sebor <msebor at gcc dot gnu.org> ---
I think the reason why the location for the last PHI argument isn't set is
because the argument is itself a PHI whose arguments have different locations:

  <bb 8> [local count: 1073741824]:
  # _16 = PHI <[pr40635.c:21:20] -1(13), [pr40635.c:19:15] s42_9(7),
[pr40635.c:28:16] -1(15), s42_21(9)>
  [pr40635.c:37:5] foo ();
  [pr40635.c:38:8] _28 = _16 < 0;
  [pr40635.c:38:8] _5 = (int) _28;
  [pr40635.c:38:8] _4 = -_5;
  return _4;

  <bb 12> [local count: 39298952]:

  <bb 9> [local count: 383953502]:
  # s42_21 = PHI <[pr40635.c:13:9] s42_18(D)(12), [pr40635.c:19:15] s42_9(14)>
  goto <bb 8>; [100.00%]

}

Even if -Wuninitialized is changed to extract the location from the
uninitialized argument to s42_21(9), it doesn't use it because it prefers to
use the location of the statement where the variable us used.  -Wuninitialized
usually prints a note pointing to the uninitialized variable but it has the
code below that guards is:

      if (xloc.file != floc.file
          || linemap_location_before_p (line_table, location, cfun_loc)
          || linemap_location_before_p (line_table, cfun->function_end_locus,
                                        location))
        inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);

Because the location of the variable is in a different function than the
current one the note isn't printed.  The patch below removes this IMO pointless
test and improves the output a bit:

pr40635.c:38:8: warning: ‘s42’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   38 |     if (sockt_rd < 0)
      |        ^
pr40635.c:13:9: note: ‘s42’ was declared here
   13 |     int s42, x;
      |         ^~~

diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 0800f596ab1..a578a596fee 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -126,8 +126,6 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var,
             const char *gmsgid, void *data, location_t phiarg_loc)
 {
   gimple *context = (gimple *) data;
-  location_t location, cfun_loc;
-  expanded_location xloc, floc;

   /* Ignore COMPLEX_EXPR as initializing only a part of a complex
      turns in a COMPLEX_EXPR with the not initialized part being
@@ -170,6 +168,7 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var,
       || TREE_NO_WARNING (expr))
     return;

+  location_t location;
   if (context != NULL && gimple_has_location (context))
     location = gimple_location (context);
   else if (phiarg_loc != UNKNOWN_LOCATION)
@@ -178,9 +177,7 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var,
     location = DECL_SOURCE_LOCATION (var);
   location = linemap_resolve_location (line_table, location,
                                       LRK_SPELLING_LOCATION, NULL);
-  cfun_loc = DECL_SOURCE_LOCATION (cfun->decl);
-  xloc = expand_location (location);
-  floc = expand_location (cfun_loc);
+
   auto_diagnostic_group d;
   if (warning_at (location, wc, gmsgid, expr))
     {
@@ -188,11 +185,7 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree
var,

       if (location == DECL_SOURCE_LOCATION (var))
        return;
-      if (xloc.file != floc.file
-         || linemap_location_before_p (line_table, location, cfun_loc)
-         || linemap_location_before_p (line_table, cfun->function_end_locus,
-                                       location))
-       inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);
+      inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);
     }
 }

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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2021-03-25 21:07 ` msebor at gcc dot gnu.org
@ 2021-03-25 21:08 ` msebor at gcc dot gnu.org
  2021-03-25 22:40 ` msebor at gcc dot gnu.org
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-25 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org

--- Comment #14 from Martin Sebor <msebor at gcc dot gnu.org> ---
Let me handle this for GCC 12.

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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2021-03-25 21:08 ` msebor at gcc dot gnu.org
@ 2021-03-25 22:40 ` msebor at gcc dot gnu.org
  2021-12-15 18:43 ` msebor at gcc dot gnu.org
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-25 22:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paulo@matos-sorge.com

--- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> ---
*** Bug 53917 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2021-03-25 22:40 ` msebor at gcc dot gnu.org
@ 2021-12-15 18:43 ` msebor at gcc dot gnu.org
  2021-12-15 18:48 ` [Bug tree-optimization/40635] [12 Regression] " msebor at gcc dot gnu.org
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-15 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
With the patch in comment #13 committed in
g:9695e1c23be5b5c55d572ced152897313ddb96ae GCC 12 prints the following for the
test case in comment #0:

pr40635.c: In function ‘server_init’:
pr40635.c:14:9: warning: ‘s42’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   14 |     int s42, x;
      |         ^~~

But it doesn't show where the uninitialized variable is used.  GCC 11 only
points to the variable's use but doesn't say which variable it is:

pr40635.c: In function ‘server_init’:
pr40635.c:39:8: warning: ‘s42’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   39 |     if (sockt_rd < 0)
      |        ^

So things have gotten both better and worse.

The reason why the GCC 12 warning doesn't point to the use is because the use
statement (_28 = _16 < 0; in basic block 8 below) has no location:

  <bb 8> [local count: 1073741824]:
  # _16 = PHI <[pr40635.c:22:20] -1(12), s42_9(7), [pr40635.c:29:16] -1(14),
s42_18(D)(11), s42_9(13)>
  [pr40635.c:38:5] foo ();
  _28 = _16 < 0;
  _5 = (int) _28;
  _4 = -_5;
  return _4;

The location can still be found in the mergephi3 dump
(pr40635.c.120t.mergephi3) and is gone from the phiopt2 dump
(pr40635.c.121t.phiopt2):

  <bb 8> [local count: 5226752]:

  <bb 9> [local count: 1073741824]:
  # _16 = PHI <[../pr40635.c:22:20] -1(3), [../pr40635.c:30:12] s42_20(7),
[../pr40635.c:29:16] -1(8)>
  [../pr40635.c:38:5] foo ();
  [../pr40635.c:39:8] if (_16 < 0)
    goto <bb 10>; [0.73%]
  else
    goto <bb 11>; [99.27%]

  <bb 10> [local count: 7838309]:

  <bb 11> [local count: 1073741824]:
  # _1 = PHI <[../pr40635.c:40:16] -1(10), [../pr40635.c:41:12] 0(9)>
  return _1;

}

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2021-12-15 18:43 ` msebor at gcc dot gnu.org
@ 2021-12-15 18:48 ` msebor at gcc dot gnu.org
  2021-12-15 19:00 ` msebor at gcc dot gnu.org
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-15 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|bogus name and location in  |[12 Regression] bogus name
                   |'may be used uninitialized' |and location in 'may be
                   |warning                     |used uninitialized' warning

--- Comment #17 from Martin Sebor <msebor at gcc dot gnu.org> ---
In GCC 11 the statement in the phipopt2 dump does have a location so this part
is a GCC 12 regression:

  <bb 8> [local count: 5226752]:

  <bb 9> [local count: 1073741824]:
  # _16 = PHI <[../pr40635.c:22:20] -1(3), [../pr40635.c:30:12] s42_20(7),
[../pr40635.c:29:16] -1(8)>
  [../pr40635.c:38:5] foo ();
  [../pr40635.c:39:8] _28 = _16 < 0;
  [../pr40635.c:39:8] _5 = (int) _28;
  [../pr40635.c:39:8] _4 = -_5;
  return _4;

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2021-12-15 18:48 ` [Bug tree-optimization/40635] [12 Regression] " msebor at gcc dot gnu.org
@ 2021-12-15 19:00 ` msebor at gcc dot gnu.org
  2021-12-15 19:14 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-15 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #18 from Martin Sebor <msebor at gcc dot gnu.org> ---
The location is still present at g:45f4e2b01b82c72b3a11ff4ad184d7edcf0e63d4 but
is lost after:

commit 9f55df63154a39d67ef5b24def7044bf87300831
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Jun 1 01:05:09 2021 +0000

    Replace conditional_replacement with match and simplify

    This is the first of series of patches to simplify phi-opt
    to use match and simplify in many cases.  This simplification
    will more things to optimize.

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2021-12-15 19:00 ` msebor at gcc dot gnu.org
@ 2021-12-15 19:14 ` pinskia at gcc dot gnu.org
  2021-12-18 10:46 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-15 19:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #18)
> The location is still present at g:45f4e2b01b82c72b3a11ff4ad184d7edcf0e63d4
> but is lost after:
> 
> commit 9f55df63154a39d67ef5b24def7044bf87300831
> Author: Andrew Pinski <apinski@marvell.com>
> Date:   Tue Jun 1 01:05:09 2021 +0000
> 
>     Replace conditional_replacement with match and simplify
>     
>     This is the first of series of patches to simplify phi-opt
>     to use match and simplify in many cases.  This simplification
>     will more things to optimize.

Yes this part is the missing part:
-      /* Set the locus to the first argument, unless is doesn't have one.  */
-      locus_0 = gimple_phi_arg_location (phi, 0);
-      locus_1 = gimple_phi_arg_location (phi, 1);
-      if (locus_0 == UNKNOWN_LOCATION)
-        locus_0 = locus_1;
-      gimple_set_location (new_stmt, locus_0);

Let me look over the weekend.

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2021-12-15 19:14 ` pinskia at gcc dot gnu.org
@ 2021-12-18 10:46 ` pinskia at gcc dot gnu.org
  2022-01-21 13:56 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-18 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note one thing I Noticed is the with the testcase in comment #0 to reproduce
the PHI-OPT issue I need to use the following options: "-O2 -Wall  -g0 
-fdisable-tree-threadfull1". jump threading actually is able to happen but then
nothing is able to move the call to foo to common code again.

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2021-12-18 10:46 ` pinskia at gcc dot gnu.org
@ 2022-01-21 13:56 ` rguenth at gcc dot gnu.org
  2022-03-17 19:25 ` msebor at gcc dot gnu.org
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-21 13:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (14 preceding siblings ...)
  2022-01-21 13:56 ` rguenth at gcc dot gnu.org
@ 2022-03-17 19:25 ` msebor at gcc dot gnu.org
  2022-03-17 22:00 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-03-17 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|msebor at gcc dot gnu.org          |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

--- Comment #21 from Martin Sebor <msebor at gcc dot gnu.org> ---
Deferring to Andrew per comment #19.

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (15 preceding siblings ...)
  2022-03-17 19:25 ` msebor at gcc dot gnu.org
@ 2022-03-17 22:00 ` pinskia at gcc dot gnu.org
  2022-05-06  8:29 ` [Bug tree-optimization/40635] [12/13 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-03-17 22:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #21)
> Deferring to Andrew per comment #19.

That part was fixed already by r12-6061-gd957d250942b13.

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

* [Bug tree-optimization/40635] [12/13 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (16 preceding siblings ...)
  2022-03-17 22:00 ` pinskia at gcc dot gnu.org
@ 2022-05-06  8:29 ` jakub at gcc dot gnu.org
  2022-11-20  3:11 ` law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06  8:29 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.0                        |12.2

--- Comment #23 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.

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

* [Bug tree-optimization/40635] [12/13 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (17 preceding siblings ...)
  2022-05-06  8:29 ` [Bug tree-optimization/40635] [12/13 " jakub at gcc dot gnu.org
@ 2022-11-20  3:11 ` law at gcc dot gnu.org
  2022-12-05 15:00 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 22+ messages in thread
From: law at gcc dot gnu.org @ 2022-11-20  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

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

--- Comment #25 from Jeffrey A. Law <law at gcc dot gnu.org> ---
So current status is if you add -fno-inline, you can see the proper
uninitialized warning in get_tcp_socket, but we only get the declaration site
of s42, not the use site.  So still broken, just in a different way then the
original report.

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

* [Bug tree-optimization/40635] [12/13 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (18 preceding siblings ...)
  2022-11-20  3:11 ` law at gcc dot gnu.org
@ 2022-12-05 15:00 ` rguenth at gcc dot gnu.org
  2022-12-05 15:51 ` cvs-commit at gcc dot gnu.org
  2023-05-08 12:21 ` [Bug tree-optimization/40635] [12 " rguenth at gcc dot gnu.org
  21 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-05 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #26 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #25)
> So current status is if you add -fno-inline, you can see the proper
> uninitialized warning in get_tcp_socket, but we only get the declaration
> site of s42, not the use site.  So still broken, just in a different way
> then the original report.

I think for this issue we have duplicates - the use is on the GIMPLE_RETURN
but those do not have locations (since we forcefully merge them), instead
a PHI merge arg should but that doesn't have a location either in this case
which is where we are lost.

We start with

  [t.c:29:12] D.2772 = s42;
  [t.c:29:12] return D.2772;

lowered to

  [t.c:29:12] D.2772 = s42;
  [t.c:29:12] goto <D.2776>;
  <D.2776>:
  return D.2772;

and with a CFG

  <bb 10> :
  [t.c:29:12] D.2772 = s42;

  <bb 11> :
  return D.2772;

SSA:

  <bb 11> :
  # _8 = PHI <[t.c:21:20] _25(4), [t.c:28:16] _27(9), [t.c:29:12] _26(10)>
  return _8;

thread1 causes the arg to split and lose locations:

@@ -47,18 +82,23 @@
   [t.c:18:34 discrim 1] if (_2 != 0B)
     goto <bb 3>; [96.34%]
   else
-    goto <bb 7>; [3.66%]
+    goto <bb 8>; [3.66%]

-  <bb 7> [local count: 75773864]:
-  # s42_4 = PHI <[t.c:19:15] s42_19(5), [t.c:19:15] s42_19(6), s42_17(D)(2)>
-  # x_6 = PHI <[t.c:22:13] 0(5), [t.c:22:13] x_21(6), [t.c:17:7] 0(2)>
+  <bb 7> [local count: 4159022]:
+  # s42_9 = PHI <s42_17(D)(2)>
+  # x_7 = PHI <[t.c:17:7] 0(2)>
+  goto <bb 9>; [100.00%]
+
+  <bb 8> [local count: 71614842]:
+  # s42_4 = PHI <[t.c:19:15] s42_19(5), [t.c:19:15] s42_19(6)>
+  # x_6 = PHI <[t.c:22:13] 0(5), [t.c:22:13] x_21(6)>
   [t.c:27:8] if (x_6 < 0)
-    goto <bb 4>; [0.73%]
+    goto <bb 4>; [0.78%]
   else
-    goto <bb 8>; [99.27%]
+    goto <bb 9>; [99.22%]

-  <bb 8> [local count: 113634474]:
-  # _8 = PHI <[t.c:21:20] -1(4), [t.c:29:12] s42_4(7), [t.c:21:20] -1(3)>
+  <bb 9> [local count: 113634474]:
+  # _8 = PHI <[t.c:21:20] -1(4), s42_4(8), [t.c:21:20] -1(3), s42_9(7)>
   return _8;

and the location is stripped by SSA update replacing _4 with its reaching
def _4 (sic!) but running into

                  gimple *stmt = SSA_NAME_DEF_STMT (reaching_def);
                  gphi *other_phi = dyn_cast <gphi *> (stmt);

                  /* Single element PHI nodes  behave like copies, so get the
                     location from the phi argument.  */
                  if (other_phi
                      && gimple_phi_num_args (other_phi) == 1)
                    locus = gimple_phi_arg_location (other_phi, 0);
                  else
                    locus = gimple_location (stmt);

using the location of the _4 def (a multi-arg PHI) which is (as usual)
UNKNOWN_LOCATION.  Fixing that fixes the location on the edge from 7
and avoids some work but then I wonder why we adjust the PHI arg location
_at all_ here (arguably we might want to replace UNKNOWN_LOCATION with
a more meaningful location but not a meaningful location with
UNKNOWN_LOCATION as we do here).

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

* [Bug tree-optimization/40635] [12/13 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (19 preceding siblings ...)
  2022-12-05 15:00 ` rguenth at gcc dot gnu.org
@ 2022-12-05 15:51 ` cvs-commit at gcc dot gnu.org
  2023-05-08 12:21 ` [Bug tree-optimization/40635] [12 " rguenth at gcc dot gnu.org
  21 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-05 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #27 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:0d14720f93a8139a7f234b2762c361e8e5da99cc

commit r13-4495-g0d14720f93a8139a7f234b2762c361e8e5da99cc
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Dec 5 16:03:21 2022 +0100

    middle-end/40635 - SSA update losing PHI arg loations

    The following fixes an issue where SSA update loses PHI argument
    locations when updating PHI nodes it didn't create as part of the
    SSA update.  For the case where the reaching def is the same as
    the current argument opt to do nothing and for the case where the
    PHI argument already has a location keep that (that's an indication
    the PHI node wasn't created as part of the update SSA process).

            PR middle-end/40635
            * tree-into-ssa.cc (rewrite_update_phi_arguments): Only
            update the argument when the reaching definition is different
            from the current argument.  Keep an existing argument
            location.

            * gcc.dg/uninit-pr40635.c: New testcase.

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

* [Bug tree-optimization/40635] [12 Regression] bogus name and location in 'may be used uninitialized' warning
       [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
                   ` (20 preceding siblings ...)
  2022-12-05 15:51 ` cvs-commit at gcc dot gnu.org
@ 2023-05-08 12:21 ` rguenth at gcc dot gnu.org
  21 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.3                        |12.4

--- Comment #28 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.

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

end of thread, other threads:[~2023-05-08 12:21 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40635-4@http.gcc.gnu.org/bugzilla/>
2013-11-01 21:56 ` [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning manu at gcc dot gnu.org
2013-12-19 10:17 ` manu at gcc dot gnu.org
2013-12-19 10:40 ` philipp at marek dot priv.at
2013-12-19 10:51 ` manu at gcc dot gnu.org
2013-12-19 10:57 ` philipp at marek dot priv.at
2013-12-19 10:59 ` philipp at marek dot priv.at
2021-03-25 21:07 ` msebor at gcc dot gnu.org
2021-03-25 21:08 ` msebor at gcc dot gnu.org
2021-03-25 22:40 ` msebor at gcc dot gnu.org
2021-12-15 18:43 ` msebor at gcc dot gnu.org
2021-12-15 18:48 ` [Bug tree-optimization/40635] [12 Regression] " msebor at gcc dot gnu.org
2021-12-15 19:00 ` msebor at gcc dot gnu.org
2021-12-15 19:14 ` pinskia at gcc dot gnu.org
2021-12-18 10:46 ` pinskia at gcc dot gnu.org
2022-01-21 13:56 ` rguenth at gcc dot gnu.org
2022-03-17 19:25 ` msebor at gcc dot gnu.org
2022-03-17 22:00 ` pinskia at gcc dot gnu.org
2022-05-06  8:29 ` [Bug tree-optimization/40635] [12/13 " jakub at gcc dot gnu.org
2022-11-20  3:11 ` law at gcc dot gnu.org
2022-12-05 15:00 ` rguenth at gcc dot gnu.org
2022-12-05 15:51 ` cvs-commit at gcc dot gnu.org
2023-05-08 12:21 ` [Bug tree-optimization/40635] [12 " rguenth 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).