https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70172
Bug ID: 70172 Summary: incorrect reinterpret_cast from integer to pointer error on invalid constexpr initialization Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The following invalid code is erroneously accepted by 5.x and 4.9.3. It is rejected by 6.0 but with an obviously incorrect error. The code is invalid not because of a cast (there is none) but because it attempts to use a null pointer to form the address of a member of an object. $ cat ~/tmp/t.c && /build/gcc-trunk/gcc/xgcc -B/build/gcc-trunk/gcc -S -Wall -Wextra -Wpedantic -xc++ ~/tmp/t.c struct S { int a, b[1]; }; constexpr S *p1 = (S*)0; constexpr int *q1 = p1->b; /home/remote/msebor/tmp/t.c:4:25: error: reinterpret_cast from integer to pointer constexpr int *q1 = p1->b; ^