Bug 71121 - [6 Regression] Spurious warning: "the address of [...] will never be NULL [-Waddress]"
Summary: [6 Regression] Spurious warning: "the address of [...] will never be NULL [-W...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.1.0
: P2 normal
Target Milestone: 6.5
Assignee: Jason Merrill
URL:
Keywords: diagnostic
Depends on:
Blocks: 55004 72766
  Show dependency treegraph
 
Reported: 2016-05-15 09:28 UTC by Olivier Goffart
Modified: 2017-09-20 08:29 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.3.0
Known to fail: 6.1.0
Last reconfirmed: 2016-05-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Goffart 2016-05-15 09:28:19 UTC
Regression in GCC 6:
The following code display a spurious warning about 
the addess of CC::mbr never being NULL despite it is not 
compared to null.

------------------------------

struct CC { void mbr(); };

constexpr auto getFunc() {
    return &CC::mbr;
}

constexpr bool xxx(void (CC::*_a)())
{
    constexpr auto f = getFunc();
    return (f == _a);
}

-------------------------------

shows a warning:

warning: the address of ‘void CC::mbr()’ will never be NULL [-Waddress]
     return (f == _a);
             ~~^~~~~

Live: http://melpon.org/wandbox/permlink/rPO9BmmGL8RxNsTI
Comment 1 Martin Sebor 2016-05-16 15:54:58 UTC
Confirmed with 6.1.0 and today's top of trunk (7.0).  Both the auto and the constexpr appear to be necessary to trigger the warning.  The regression appears to have been introduced in r234940.
Comment 2 Jason Merrill 2016-07-21 06:06:05 UTC
Author: jason
Date: Thu Jul 21 06:05:33 2016
New Revision: 238559

URL: https://gcc.gnu.org/viewcvs?rev=238559&root=gcc&view=rev
Log:
	PR c++/71121 - -Waddress, constexpr, and PMFs.

	* cp-gimplify.c (cp_fully_fold): First call maybe_constant_value.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Waddress-4.C
Removed:
    trunk/gcc/testsuite/g++.dg/warn/overflow-warn-7.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-gimplify.c
Comment 3 Jason Merrill 2016-07-21 06:25:06 UTC
Fixed on trunk so far.
Comment 4 Richard Biener 2016-08-22 08:51:22 UTC
GCC 6.2 is being released, adjusting target milestone.
Comment 5 Richard Biener 2016-08-22 08:52:15 UTC
GCC 6.2 is being released, adjusting target milestone.
Comment 6 Richard Biener 2016-08-22 08:57:39 UTC
GCC 6.2 is being released, adjusting target milestone.
Comment 7 Richard Biener 2016-08-22 08:59:02 UTC
GCC 6.2 is being released, adjusting target milestone.
Comment 8 Jakub Jelinek 2016-12-21 10:59:46 UTC
GCC 6.3 is being released, adjusting target milestone.
Comment 9 Richard Biener 2017-07-04 08:50:42 UTC
GCC 6.4 is being released, adjusting target milestone.
Comment 10 Paolo Carlini 2017-09-20 08:29:21 UTC
I guess we could as well close this. Jason?