It looks like there is a regression in trunk(20171107 on CE) that allows reinterpret_casts in constant expressions. https://gcc.godbolt.org/z/m7Qytn using size_t = decltype(sizeof(int)); constexpr char const * func( char const * ptr ) { return reinterpret_cast<char const *>( ptr ); } static_assert( func( nullptr ) == nullptr ); template<size_t N> constexpr char const * func2( char const (&s)[N] ) { return reinterpret_cast<char const *>( s ); } static_assert( *func2( "Hello" ) == 'H' ); I think this should be ill formed with a diag according to the following links, but it is allowed https://eel.is/c++draft/expr.const#4.15 https://eel.is/c++draft/dcl.pre#6
sorry, posted incorrect CE link, but code below demonstrates it
I see no regression, it has always been accepted by G++. Possibly a dup of Bug 82304.
This particular cast, from const char array to const char pointer, is implicit so static_cast suffices (and the reinterpret_cast is implictly a static_cast). Editing your code sample to change reinterpret_cast to static_cast it is accepted without diagnostic on gcc, clang, msvc, icc https://gcc.godbolt.org/z/6a694c The final comment on the bug linked as a possible duplicate shows that some fixes were committed last month, fixing other cases. I guess this particular case can be closed.
I mis-read this so was too hasty in suggesting "can be closed". The standard states that a expression evaluation fails to be a constant expression if it evaluates "reinterpret_cast" (i.e., by named token, not by the actual strength of cast required, so seems to be the intent). It's a 50/50 split with gcc & icc accepting, clang and msvc rejecting https://gcc.godbolt.org/z/drdT66