This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/86354] New: Address comparison not a constant expression
- From: "pdimov at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Jun 2018 23:26:39 +0000
- Subject: [Bug c++/86354] New: Address comparison not a constant expression
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86354
Bug ID: 86354
Summary: Address comparison not a constant expression
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pdimov at gmail dot com
Target Milestone: ---
The following code:
```
struct X {};
struct Y: X {};
struct Z: X {};
extern Y y;
extern Z z;
constexpr X const& x1() { return y; }
constexpr X const& x2() { return z; }
static_assert( &x1() != &x2() );
```
yields (with g++ 7.3 and 8.1)
```
testbed2017.cpp:12:1: error: non-constant condition for static assertion
static_assert( &x1() != &x2() );
^~~~~~~~~~~~~
testbed2017.cpp:12:22: error: '(((const X*)(& y)) != ((const X*)(& z)))' is not
a constant expression
static_assert( &x1() != &x2() );
~~~~~~^~~~~~~~
```
but other compilers accept it.