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.