Is it allowed to declare a non-constant link as constexpr? Code example:
int x = 1;
constexpr int& r = x;
This is accepted by gcc and clang (I tried several current and past versions of both, back in C ++ 11, and all this was accepted). However, I think this should not be accepted because C ++ 14 [dcl.constexpr / 9] says:
if the constexpr specifier is used in the link declaration, the expression that appears in its initializer must be a constant expression
and is xnot a constant expression.
The language in the latest C ++ 17 project [dcl.constexpr] has changed and does not even mention more links constexpr, I can’t understand what it is trying to say about them.
source
share