Fed*_*dor 5 c++ language-lawyer constexpr
在以下代码中,比较static constexpr变量的指针x和是否不相等:y
int main() {
static constexpr int x = 1;
static constexpr int y = 2;
static_assert( &x != &y );
}
Run Code Online (Sandbox Code Playgroud)
它在 Clang 中工作正常,但在打印的 GCC 中却不行
error: non-constant condition for static assertion
error: '((& x) != (& y))' is not a constant expression
Run Code Online (Sandbox Code Playgroud)
演示: https: //gcc.godbolt.org/z/3WdqP49Gq
这只是 GCC 中的一个错误吗?