public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
@ 2015-02-27 18:51 ulfalizer at gmail dot com
  2015-02-27 19:10 ` [Bug c/65244] " ulfalizer at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: ulfalizer at gmail dot com @ 2015-02-27 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65244
           Summary: Bogus -Wmaybe-uninitialized warning with
                    posix_memalign() and -Og
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ulfalizer at gmail dot com

The warning

  posix_memalign_warn.c: In function ‘f’:
  posix_memalign_warn.c:9:5: warning: ‘ptr’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
       return ptr;
       ^

is generated when compiling the following with

  gcc -Og -Wmaybe-uninitialized -c posix_memalign_warn.c

No warning is produced for -O0/1/2/3/fast.


#include <stdlib.h>

void *f(void) {
    void *ptr;

    if (posix_memalign(&ptr, 16, 256) != 0)
        exit(EXIT_FAILURE);

    return ptr;
}
>From gcc-bugs-return-478776-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 27 17:20:42 2015
Return-Path: <gcc-bugs-return-478776-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 117520 invoked by alias); 27 Feb 2015 17:20:41 -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 117138 invoked by uid 48); 27 Feb 2015 17:20:38 -0000
From: "bergner at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65242] [5 Regression] ICE (in gen_add2_insn, at optabs.c:4761) on powerpc64le-linux-gnu
Date: Fri, 27 Feb 2015 18:54:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: bergner 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: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-65242-4-TJMy9neNla@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65242-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65242-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-02/txt/msg03108.txt.bz2
Content-length: 499

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

Peter Bergner <bergner at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-27
     Ever confirmed|0                           |1

--- Comment #1 from Peter Bergner <bergner at gcc dot gnu.org> ---
Confirmed, I'll have a look.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
@ 2015-02-27 19:10 ` ulfalizer at gmail dot com
  2015-02-27 21:02 ` manu at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ulfalizer at gmail dot com @ 2015-02-27 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Ulf Magnusson <ulfalizer at gmail dot com> ---
This warning did not occur for GCC 4.8.2 (or whatever the most recent GCC
version is on Ubuntu 14.04) by the way.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
  2015-02-27 19:10 ` [Bug c/65244] " ulfalizer at gmail dot com
@ 2015-02-27 21:02 ` manu at gcc dot gnu.org
  2015-02-27 21:24 ` ulfalizer at gmail dot com
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: manu at gcc dot gnu.org @ 2015-02-27 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-02-27
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
I cannot reproduce this with GCC 5.0 on x86_64-linux-gnu.

Please, we need a minimal preprocessed testcase:
https://gcc.gnu.org/bugs/minimize.html
>From gcc-bugs-return-478788-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 27 20:31:50 2015
Return-Path: <gcc-bugs-return-478788-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 86037 invoked by alias); 27 Feb 2015 20:31:50 -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 85990 invoked by uid 48); 27 Feb 2015 20:31:44 -0000
From: "howarth at bromo dot med.uc.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
Date: Fri, 27 Feb 2015 21:20: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.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: howarth at bromo dot med.uc.edu
X-Bugzilla-Status: WAITING
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: cc
Message-ID: <bug-65244-4-9nAgRBUfHH@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65244-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65244-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-02/txt/msg03120.txt.bz2
Content-length: 457

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

howarth at bromo dot med.uc.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |howarth at bromo dot med.uc.edu

--- Comment #3 from howarth at bromo dot med.uc.edu ---
This warning occurs with gcc 4.9.2 on x86_64-apple-darwin14 but not with
current gcc trunk.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
  2015-02-27 19:10 ` [Bug c/65244] " ulfalizer at gmail dot com
  2015-02-27 21:02 ` manu at gcc dot gnu.org
@ 2015-02-27 21:24 ` ulfalizer at gmail dot com
  2015-02-27 21:48 ` manu at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ulfalizer at gmail dot com @ 2015-02-27 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Ulf Magnusson <ulfalizer at gmail dot com> ---
Created attachment 34894
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34894&action=edit
-Wmaybe-uninitialized-warning with -Og with GCC 4.9.1

The testcase was in the comment. I'm attaching it.

I don't have access to GCC 5.0. Perhaps the behavior changed between GCC 4.9.1
and that version.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (2 preceding siblings ...)
  2015-02-27 21:24 ` ulfalizer at gmail dot com
@ 2015-02-27 21:48 ` manu at gcc dot gnu.org
  2015-02-27 22:02 ` ulfalizer at gmail dot com
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: manu at gcc dot gnu.org @ 2015-02-27 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Ulf Magnusson from comment #4)
> Created attachment 34894 [details]
> -Wmaybe-uninitialized-warning with -Og with GCC 4.9.1
> 
> The testcase was in the comment. I'm attaching it.

Please read the link that I posted. We need "preprocessed" code because the
stdlib.h of Apple may be doing something weird which is confusing GCC.
>From gcc-bugs-return-478792-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 27 20:43:45 2015
Return-Path: <gcc-bugs-return-478792-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22568 invoked by alias); 27 Feb 2015 20:43:44 -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 22494 invoked by uid 48); 27 Feb 2015 20:43:41 -0000
From: "ulfalizer at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
Date: Fri, 27 Feb 2015 21:58: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.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ulfalizer at gmail dot com
X-Bugzilla-Status: WAITING
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-65244-4-pKljshJbM2@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65244-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65244-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-02/txt/msg03124.txt.bz2
Content-length: 517

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

--- Comment #6 from Ulf Magnusson <ulfalizer at gmail dot com> ---
Comment on attachment 34894
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id4894
-Wmaybe-uninitialized-warning with -Og with GCC 4.9.1

void exit(int __status) __attribute__ ((__noreturn__));
int posix_memalign(void **__memptr, __SIZE_TYPE__ __alignment, __SIZE_TYPE__
__size);

void *f(void) {
    void *ptr;

    if (posix_memalign(&ptr, 16, 256) != 0)
        exit(1);

    return ptr;
}


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (3 preceding siblings ...)
  2015-02-27 21:48 ` manu at gcc dot gnu.org
@ 2015-02-27 22:02 ` ulfalizer at gmail dot com
  2015-02-27 22:07 ` howarth at bromo dot med.uc.edu
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ulfalizer at gmail dot com @ 2015-02-27 22:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Ulf Magnusson <ulfalizer at gmail dot com> ---
Created attachment 34895
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34895&action=edit
Headerless version

Sorry -- thought my previous action would edit the attachment directly.

I've now attached an equivalent headerless version (by keeping the relevant
parts of the preprocessed source). This is on Ubuntu 14.10 BTW, not OS X.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (4 preceding siblings ...)
  2015-02-27 22:02 ` ulfalizer at gmail dot com
@ 2015-02-27 22:07 ` howarth at bromo dot med.uc.edu
  2015-02-27 23:04 ` ulfalizer at gmail dot com
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: howarth at bromo dot med.uc.edu @ 2015-02-27 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from howarth at bromo dot med.uc.edu ---
I wonder if this is the same issue as
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63748 which was fixed in trunk by
r217317...

2014-11-10  Patrick Palka  <ppalka@gcc.gnu.org>

gcc/
    PR middle-end/63748
    * tree-ssa-propagate.c (may_propagate_copy): Allow propagating
    SSA copies whose source and destination names both occur in
    abnormal PHIs.

gcc/testsuite/
    PR middle-end/63748
    * gcc.dg/pr63748.c: New testcase.

but never back ported to gcc-4_9-branch.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (5 preceding siblings ...)
  2015-02-27 22:07 ` howarth at bromo dot med.uc.edu
@ 2015-02-27 23:04 ` ulfalizer at gmail dot com
  2015-02-27 23:21 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ulfalizer at gmail dot com @ 2015-02-27 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Ulf Magnusson <ulfalizer at gmail dot com> ---
Created attachment 34897
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34897&action=edit
Reduce testcase using __builtin_posix_memalign().

The warning goes away with -fno-builtin. I didn't realize posix_memalign()
existed as a builtin (documentation bug?).

Attaching a further reduced testcase.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (6 preceding siblings ...)
  2015-02-27 23:04 ` ulfalizer at gmail dot com
@ 2015-02-27 23:21 ` pinskia at gcc dot gnu.org
  2015-02-28  1:24 ` manu at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-02-27 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This works in GCC 5.0.


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

* [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (7 preceding siblings ...)
  2015-02-27 23:21 ` pinskia at gcc dot gnu.org
@ 2015-02-28  1:24 ` manu at gcc dot gnu.org
  2021-03-31 19:05 ` [Bug middle-end/65244] " msebor at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: manu at gcc dot gnu.org @ 2015-02-28  1:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
                 CC|manu at gcc dot gnu.org            |
      Known to work|                            |4.8.2, 5.0

--- Comment #11 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
I don't have GCC 4.9.1 to try, but I would assume it is confirmed according to
Jack.

If it did not trigger in 4.8, then it is technically a regression.

__builtin_posix_memalign was introduced in r207595.
>From gcc-bugs-return-478807-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 27 23:04:23 2015
Return-Path: <gcc-bugs-return-478807-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 114830 invoked by alias); 27 Feb 2015 23:04:23 -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 114562 invoked by uid 48); 27 Feb 2015 23:04:19 -0000
From: "howarth at bromo dot med.uc.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
Date: Sat, 28 Feb 2015 05:08: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.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: howarth at bromo dot med.uc.edu
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-65244-4-m4IPlh4fgR@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65244-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65244-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-02/txt/msg03139.txt.bz2
Content-length: 207

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

--- Comment #12 from howarth at bromo dot med.uc.edu ---
The issue also exists in current gcc-4_9-branch but applying r217317 doesn't
eliminate it there.


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

* [Bug middle-end/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (8 preceding siblings ...)
  2015-02-28  1:24 ` manu at gcc dot gnu.org
@ 2021-03-31 19:05 ` msebor at gcc dot gnu.org
  2022-08-30  8:27 ` [Bug tree-optimization/65244] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-31 19:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2015-02-27 00:00:00         |2021-3-31
      Known to fail|                            |10.2.0, 11.0, 4.9.4, 5.5.0,
                   |                            |6.4.0, 7.2.0, 8.3.0, 9.1.0
      Known to work|4.8.2, 5.0                  |
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning with -Og disappeared with r212559 but still comes back on trunk
with -Og -ftree-bit-ccp.  With that, as the comment in gimple-low.c says, a
call to posix_memalign() is lowered into:

    void *tem;
     res = posix_memalign (&tem, align, size);
     if (res == 0)
       ptr = __builtin_assume_aligned (tem, align);

and at -Og it looks like the two conditionals don't get cleaned up as nicely as
at -O1 and lead to an IL that the warning is designed to trigger on.  This
could be handled by the warning but unless this can come up with other
(especially non-builtin) functions it may not be worth the trouble.

$ cat pr65244.c && gcc -Og -S -Wall -ftree-bit-ccp
-fdump-tree-uninit=/dev/stdout pr65244.c
void exit(int __status) __attribute__ ((__noreturn__));
int posix_memalign(void **__memptr, __SIZE_TYPE__ __alignment, __SIZE_TYPE__
__size);

void *f(void) {
    void *ptr;

    if (posix_memalign(&ptr, 16, 256) != 0)
        exit(1);

    return ptr;
}

;; Function f (f, funcdef_no=0, decl_uid=1949, cgraph_uid=1, symbol_order=0)

pr65244.c: In function ‘f’:
pr65244.c:10:12: warning: ‘ptr’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   10 |     return ptr;
      |            ^~~
pr65244.c:5:11: note: ‘ptr’ was declared here
    5 |     void *ptr;
      |           ^~~
void * f ()
{
  void * D.1957;
  void * ptr;
  int _1;
  void * _6;

  <bb 2> [local count: 1073741824]:
  _1 = posix_memalign (&D.1957, 16, 256);
  if (_1 == 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 7>; [50.00%]

  <bb 7> [local count: 536870912]:
  goto <bb 4>; [100.00%]

  <bb 3> [local count: 536870913]:
  _6 = D.1957;

  <bb 4> [local count: 1073741824]:
  # ptr_2 = PHI <ptr_5(D)(7), _6(3)>
  if (_1 != 0)
    goto <bb 5>; [0.04%]
  else
    goto <bb 6>; [99.96%]

  <bb 5> [local count: 429496]:
  exit (1);

  <bb 6> [local count: 1073312329]:
  return ptr_2;

}

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

* [Bug tree-optimization/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (9 preceding siblings ...)
  2021-03-31 19:05 ` [Bug middle-end/65244] " msebor at gcc dot gnu.org
@ 2022-08-30  8:27 ` rguenth at gcc dot gnu.org
  2022-08-31  9:07 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-30  8:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
To trigger the diagnostic in GCC 12+ you also need -fno-thread-jumps.  The
issue
with this testcase is that we have

  <bb 4> [local count: 1073741824]:
  # ptr_2 = PHI <ptr_5(D)(7), _6(3)>
  if (_1 != 0)
    goto <bb 5>; [0.04%]
  else
    goto <bb 6>; [99.96%]

  <bb 5> [local count: 429496]:
  exit (1);

  <bb 6> [local count: 1073312329]:
  return ptr_2;

and predicate::init_from_control_deps does

          /* Skip if there is essentially one succesor.  */
          if (EDGE_COUNT (e->src->succs) == 2)
            {
              edge e1;
              edge_iterator ei1;
              bool skip = false;

              FOR_EACH_EDGE (e1, ei1, e->src->succs)
                {
                  if (EDGE_COUNT (e1->dest->succs) == 0)
                    {
                      skip = true;
                      break;
                    }
                }
              if (skip)
                continue;
            }

which causes us to ignore the _1 != 0 predicate on the use.  I'm not sure
what's the reason on this - we have put a limit on the number of edges in
the chain and the number of chains, so this can't be to remain within
such limit.  Simply skipping some predicates can also make the defined
domain larger which is against the intent of the pass.

Testing removal of this premature optimization(?).

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

* [Bug tree-optimization/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (10 preceding siblings ...)
  2022-08-30  8:27 ` [Bug tree-optimization/65244] " rguenth at gcc dot gnu.org
@ 2022-08-31  9:07 ` rguenth at gcc dot gnu.org
  2022-08-31 11:04 ` cvs-commit at gcc dot gnu.org
  2022-08-31 11:04 ` rguenth at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-31  9:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so the "optimization" is needed on the DEF side as

extern void __attribute__((noreturn)) abort (void);

int foo (int flag, int val)
{
  int tem;
  if (flag)
    {
      if (val == 0)
        abort ();
      tem = val;
    }
  /* large - prevent jump threading */
  __asm__ volatile ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  if (flag)
    return tem;
  return 0;
}

shows (I'll add that testcase).  Otherwise we pick up

        ((NOT (val_5(D) == 0)) AND (flag_3(D) != 0))

as the condition on which 'tem' is well-defined and the guard of the use is
just

        ((flag_3(D) != 0))

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

* [Bug tree-optimization/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (11 preceding siblings ...)
  2022-08-31  9:07 ` rguenth at gcc dot gnu.org
@ 2022-08-31 11:04 ` cvs-commit at gcc dot gnu.org
  2022-08-31 11:04 ` rguenth at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-31 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 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:40f347881ade08fe9c0f8b527f8b54bd53aed195

commit r13-2305-g40f347881ade08fe9c0f8b527f8b54bd53aed195
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Aug 30 10:31:26 2022 +0200

    tree-optimization/65244 - include asserts in predicates for uninit

    When uninit computes the actual predicates from the control dependence
    edges it currently skips those that are assert-like (where one edge
    leads to a block which ends in a noreturn call).  That leads to
    bogus uninit diagnostics when applied on the USE side.

            PR tree-optimization/65244
            * gimple-predicate-analysis.h (predicate::init_from_control_deps):
            Add argument to specify whether the predicate is for the USE.
            * gimple-predicate-analysis.cc (predicate::init_from_control_deps):
            Also include predicates effective fallthru control edges when
            the predicate is for the USE.

            * gcc.dg/uninit-pr65244-2.c: New testcase.

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

* [Bug tree-optimization/65244] Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
  2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
                   ` (12 preceding siblings ...)
  2022-08-31 11:04 ` cvs-commit at gcc dot gnu.org
@ 2022-08-31 11:04 ` rguenth at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-31 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 12+ and for GCC 13 even with jump threading disabled.

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

end of thread, other threads:[~2022-08-31 11:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27 18:51 [Bug c/65244] New: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og ulfalizer at gmail dot com
2015-02-27 19:10 ` [Bug c/65244] " ulfalizer at gmail dot com
2015-02-27 21:02 ` manu at gcc dot gnu.org
2015-02-27 21:24 ` ulfalizer at gmail dot com
2015-02-27 21:48 ` manu at gcc dot gnu.org
2015-02-27 22:02 ` ulfalizer at gmail dot com
2015-02-27 22:07 ` howarth at bromo dot med.uc.edu
2015-02-27 23:04 ` ulfalizer at gmail dot com
2015-02-27 23:21 ` pinskia at gcc dot gnu.org
2015-02-28  1:24 ` manu at gcc dot gnu.org
2021-03-31 19:05 ` [Bug middle-end/65244] " msebor at gcc dot gnu.org
2022-08-30  8:27 ` [Bug tree-optimization/65244] " rguenth at gcc dot gnu.org
2022-08-31  9:07 ` rguenth at gcc dot gnu.org
2022-08-31 11:04 ` cvs-commit at gcc dot gnu.org
2022-08-31 11:04 ` 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).