https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82304
Bug ID: 82304 Summary: GCC compiles constexpr function with double reinterpret_cast in a constant context Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vladimir.krivopalov at gmail dot com Target Milestone: --- The following code compiles fine with GCC (-std=c++14) although normally it should be rejected: #include <cstdint> inline constexpr const char* testfunc(const char* p) { return reinterpret_cast<const char*> ( reinterpret_cast<uintptr_t>(p)); } int main(int argc, char** argv) { static constexpr const char* second = testfunc("Hello"); } The C+14 standard prohibits use of reinterpret_cast in constexpr functions: [expr.const]/2.11 and [expr.const]/2.13