Can a static constexpr member variable refer to its own address?

Viewed 84

I've recently wanted to write code like this:

struct FunnyBusiness {
    static constexpr const void *IDENTITY = (const void *)&IDENTITY;
};

However, GCC (10.2) rejects this code ("IDENTITY was not declared in this scope") while Clang (11.0) compiles it just fine.

Is it legal for the initializer of a static constexpr member variable to take the address of the member variable itself?

0 Answers
Related