Comparison of pointers to static constexpr variables in a constant expression

Viewed 84

In the following code, pointers to static constexpr variables x and y are compared for not-equality:

int main() {
    static constexpr int x = 1;
    static constexpr int y = 2;
    static_assert( &x != &y );
}

It works fine in Clang, but not in GCC which prints

error: non-constant condition for static assertion
error: '((& x) != (& y))' is not a constant expression

Demo: https://gcc.godbolt.org/z/3WdqP49Gq

Is it just a bug in GCC?

0 Answers
Related