https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70151
Bug ID: 70151 Summary: forming out of bounds constexpr pointer accepted 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: --- In the following program, the initializer of the constexpr pointer p has undefined behavior. As a result, the initializer is not a /core constant expression/ which makes the program ill-formed and subject to a requirement for a diagnostic. However, GCC 6.0 and all supported versions before it that implement constexpr silently accept it. $ cat z.c && /home/msebor/build/gcc-trunk-svn/gcc/xg++ -B/home/msebor/build/gcc-trunk-svn/gcc -S z.c constexpr int a [] = { 1 }; constexpr const int *p = a - 1; The EDG eccp front end rejects the program with the following output: "z.c", line 2: warning: pointer points outside of underlying object constexpr const int *p = a - 1; ^ "z.c", line 2: error: expression must have a constant value constexpr const int *p = a - 1; ^ "z.c", line 2: warning: variable "p" was declared but never referenced constexpr const int *p = a - 1; ^ 1 error detected in the compilation of "z.c".