public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/65686] New: incorrect warning maybe-uninitialized
@ 2015-04-07 12:25 dimhen at gmail dot com
  2015-04-14 11:14 ` [Bug middle-end/65686] [4.9 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int' dimhen at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dimhen at gmail dot com @ 2015-04-07 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65686
           Summary: incorrect warning maybe-uninitialized
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimhen at gmail dot com

gcc version 5.0.0 20150404 (experimental) [trunk revision 221866] (GCC)

$ cat x.i
typedef unsigned mytype; // 'int' fixes issue

struct S {
  mytype *pu;
};

mytype f(struct S *e)
{
  mytype x;
  if(&x != e->pu)
    __builtin_memcpy(&x, e->pu, sizeof(unsigned));
  return x;
}

$ gcc -fpreprocessed -Werror -Wall -O2 -c x.i
x.i: In function ‘f’:
x.i:9:10: error: ‘x’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   mytype x;
          ^
cc1: all warnings being treated as error
>From gcc-bugs-return-482861-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 07 12:29:45 2015
Return-Path: <gcc-bugs-return-482861-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 41625 invoked by alias); 7 Apr 2015 12:29: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 41573 invoked by uid 48); 7 Apr 2015 12:29:42 -0000
From: "rainer@emrich-ebersheim.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/65559] [5 Regression] lto1.exe: internal compiler error: in read_cgraph_and_symbols, at lto/lto.c:2947
Date: Tue, 07 Apr 2015 12:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rainer@emrich-ebersheim.de
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-65559-4-nxVtUmGg6i@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65559-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65559-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: 2015-04/txt/msg00413.txt.bz2
Content-length: 469

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide559

--- Comment #10 from Rainer Emrich <rainer@emrich-ebersheim.de> ---
(In reply to Richard Biener from comment #8)
> Unfortunately -Wl,-debug is missing ;)
Ok, I uploaded a version including -Wl,-debug

>
> It would be interesting to see the lto-wrapper invocation (is there sth like
> strace on mingw?) and to eventually attach to lto-wrapper with a debugger...
I can't tell how to do this. Kai can you have a look?


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

* [Bug middle-end/65686] [4.9 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
@ 2015-04-14 11:14 ` dimhen at gmail dot com
  2015-04-14 18:36 ` [Bug middle-end/65686] [5/6 " dimhen at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dimhen at gmail dot com @ 2015-04-14 11:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Dmitry G. Dyachenko <dimhen at gmail dot com> ---
r212420 PASS
r212492 FAIL

gcc version 4.10.0 20140710 (experimental) [trunk revision 212420] (GCC)
gcc version 4.10.0 20140713 (experimental) [trunk revision 212492] (GCC)


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

* [Bug middle-end/65686] [5/6 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
  2015-04-14 11:14 ` [Bug middle-end/65686] [4.9 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int' dimhen at gmail dot com
@ 2015-04-14 18:36 ` dimhen at gmail dot com
  2015-04-15  7:46 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dimhen at gmail dot com @ 2015-04-14 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Dmitry G. Dyachenko <dimhen at gmail dot com> ---
start FAIL r212452 (fix for PR middle-end/61473)


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

* [Bug middle-end/65686] [5/6 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
  2015-04-14 11:14 ` [Bug middle-end/65686] [4.9 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int' dimhen at gmail dot com
  2015-04-14 18:36 ` [Bug middle-end/65686] [5/6 " dimhen at gmail dot com
@ 2015-04-15  7:46 ` rguenth at gcc dot gnu.org
  2015-06-18 11:50 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-04-15  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic,
                   |                            |missed-optimization
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-04-15
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
   Target Milestone|---                         |5.2
     Ever confirmed|0                           |1

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's (good)

  <bb 2>:
  _4 = e_3(D)->pu;
  if (&x != _4)
    goto <bb 3>;
  else
    goto <bb 5>;

  <bb 5>:
  goto <bb 4>;

  <bb 3>:
  _5 = MEM[(char * {ref-all})_4];
  MEM[(char * {ref-all})&x] = _5;

  <bb 4>:
  _7 = x;
  x ={v} {CLOBBER};
  return _7;

vs. (bad)

  <bb 2>:
  _4 = e_3(D)->pu;
  if (&x != _4)
    goto <bb 4>;
  else
    goto <bb 3>;

  <bb 3>:
  pretmp_9 = x;
  goto <bb 5>;

  <bb 4>:
  _5 = MEM[(char * {ref-all})_4];

  <bb 5>:
  # prephitmp_10 = PHI <pretmp_9(3), _5(4)>
  x ={v} {CLOBBER};
  return prephitmp_10;

that's a missed PRE opportunity in the good case (not sure why we use
unsigned int for the memcpy inlining - ah, because it goes the new
single load/store case in gimple_fold_builtin_memory_op).  PRE should
still be able to handle.

Only after PRE we hit the very special case where uninit warns about memory
reads (no store before the reads).  For this case inconsistencies are
very much expected...

But the testcase also shows a missed optimization opportunity because
&x can never be equal to e->pu (PR13962).


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

* [Bug middle-end/65686] [5/6 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
                   ` (2 preceding siblings ...)
  2015-04-15  7:46 ` rguenth at gcc dot gnu.org
@ 2015-06-18 11:50 ` rguenth at gcc dot gnu.org
  2015-06-18 12:09 ` dimhen at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-18 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |13962

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that you are basically relying on optimization to remove the uninitialized
load.

Where does this obfuscated 'return *(e->pu)' come from?

Related to PR13962 (to simplify the compare to false)


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=13962
[Bug 13962] [tree-ssa] make "fold" use alias information to optimize pointer
comparisons


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

* [Bug middle-end/65686] [5/6 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
                   ` (3 preceding siblings ...)
  2015-06-18 11:50 ` rguenth at gcc dot gnu.org
@ 2015-06-18 12:09 ` dimhen at gmail dot com
  2015-06-30 10:17 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dimhen at gmail dot com @ 2015-06-18 12:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dmitry G. Dyachenko <dimhen at gmail dot com> ---
(In reply to Richard Biener from comment #5)
> 
> Where does this obfuscated 'return *(e->pu)' come from?

If I remove aggregate then there are no warning.


i.e. this code produce no warning

mytype f(mytype *pu)
{
  mytype x;
  if(&x != pu)
    __builtin_memcpy(&x, pu, sizeof(unsigned));
  return x;
}


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

* [Bug middle-end/65686] [5/6 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
                   ` (4 preceding siblings ...)
  2015-06-18 12:09 ` dimhen at gmail dot com
@ 2015-06-30 10:17 ` rguenth at gcc dot gnu.org
  2015-07-16  9:11 ` rguenth at gcc dot gnu.org
  2024-05-16 12:47 ` [Bug middle-end/65686] [5/6/7 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-30 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

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


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

* [Bug middle-end/65686] [5/6 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
                   ` (5 preceding siblings ...)
  2015-06-30 10:17 ` rguenth at gcc dot gnu.org
@ 2015-07-16  9:11 ` rguenth at gcc dot gnu.org
  2024-05-16 12:47 ` [Bug middle-end/65686] [5/6/7 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.2                         |5.3

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.


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

* [Bug middle-end/65686] [5/6/7 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int'
  2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
                   ` (6 preceding siblings ...)
  2015-07-16  9:11 ` rguenth at gcc dot gnu.org
@ 2024-05-16 12:47 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-16 12:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65686
Bug 65686 depends on bug 13962, which changed state.

Bug 13962 Summary: [tree-ssa] make "fold" use alias information to optimize pointer comparisons
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=13962

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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

end of thread, other threads:[~2024-05-16 12:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 12:25 [Bug middle-end/65686] New: incorrect warning maybe-uninitialized dimhen at gmail dot com
2015-04-14 11:14 ` [Bug middle-end/65686] [4.9 regression] inconsistent warning maybe-uninitialized: warn about 'unsigned', not warn about 'int' dimhen at gmail dot com
2015-04-14 18:36 ` [Bug middle-end/65686] [5/6 " dimhen at gmail dot com
2015-04-15  7:46 ` rguenth at gcc dot gnu.org
2015-06-18 11:50 ` rguenth at gcc dot gnu.org
2015-06-18 12:09 ` dimhen at gmail dot com
2015-06-30 10:17 ` rguenth at gcc dot gnu.org
2015-07-16  9:11 ` rguenth at gcc dot gnu.org
2024-05-16 12:47 ` [Bug middle-end/65686] [5/6/7 " 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).