Is the result of static_casting itself a constexpr pointer constant expression?
clang rejects this code, which gcc allows:
int main() {
static constexpr const void *vp = nullptr;
static constexpr const char *cp = static_cast<const char*>(vp);
}
With the following:
error: constexpr variable 'cp' must be initialized by a constant expression
static constexpr const char *cp = static_cast<const char*>(vp);
After reading the final list in N3797 5.9 / 2 I don't see anything that prohibits use static_cast
in constant expression, Am I looking in the wrong place or misunderstanding something? Or should I open a bug against clang?
source to share
Well, the C ++ 14 standard (and your (not final) draft!) Requires that
a conditional expression
e
is a constant constant expression if the evaluatione
, following the rules of the abstract machine (1.9), evaluates one of the following expressions:- conversion from the cv
void *
type to the object pointer type;
source to share