https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89074
Bug ID: 89074
Summary: valid pointer equality constexpr comparison rejected
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tadeus.prastowo at unitn dot it
Target Milestone: ---
struct A {
static constexpr int v {1};
};
struct B {
static constexpr int v {1};
};
static_assert(&A::v == &A::v, "1");
static_assert(&A::v != &B::v, "2");
According to http://eel.is/c++draft/expr.eq#3.3, the second static_assert
should be successful. But, while clang, icc, and msvc accept, gcc version
9.0.0 20190113 fails to even raise the assertion with the following message
(https://www.godbolt.org/z/UtjS8v):
/tmp/x.cpp:10:21: error: non-constant condition for static assertion
10 | static_assert(&A::v != &B::v, "2");
| ~~~~~~^~~~~~~~
/tmp/x.cpp:10:21: error: ‘((& A::v) != (& B::v))’ is not a constant expression