clang is rejecting 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 listing in N3797 5.9/2 I don't see anything that forbids static_cast
's use in a constant expression. Am I looking in the wrong place or misreading something? Or should I open a bug against clang?
Well, the C++14 standard (and your (non-final) draft!) mandates that
A conditional-expression
e
is a core constant expression unless the evaluation ofe
, following the rules of the abstract machine (1.9), would evaluate one of the following expressions:— a conversion from type cv
void *
to a pointer-to-object type;