This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70170] New: [6 regression] bogus not a constant expression error comparing pointer to array to null
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 Mar 2016 19:47:59 +0000
- Subject: [Bug c++/70170] New: [6 regression] bogus not a constant expression error comparing pointer to array to null
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70170
Bug ID: 70170
Summary: [6 regression] bogus not a constant expression error
comparing pointer to array to null
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 example compiles successfully with 4.9.3 and 5 but fails with
6.0. Note that the older compilers issue "warning: the address of âsâ will
ever be NULL [-Waddress]" for the "p0 == 0" expression. GCC 6 does not. That
seems like another regression. Without bisecting it I suspect the delayed
folding changes to be responsible for both of these new problems.
$ cat t.c && /build/gcc-trunk/gcc/xgcc -B/build/gcc-trunk/gcc -S -Wall -Wextra
-Wpedantic -xc++ t.c
struct S { int a, b[1]; } s;
constexpr S *p0 = &s;
constexpr int *q0 = p0->b;
constexpr bool b0 = p0 == 0;
constexpr bool b1 = q0 == 0;
t.c:7:24: error: â((((int*)(& s)) + 4u) == 0u)â is not a constant expression
constexpr bool b1 = q0 == 0;
~~~^~~~