[Bug c++/67376] [5/6 regression] Comparison with pointer to past-the-end of array fails inside constant expression

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 22 11:42:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67376

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 37103
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37103&action=edit
gcc6-pr67376.patch

Untested fix.  The problem is that while fold_binary_loc attempts to
canonicalize the order of arguments, in this case neither argument is a
constant that would be forced into the second argument, so we need to check
both variants, because EQ_EXPR/NE_EXPR is commutative.

Another possibility is to move this folding to match.pd instead, but dunno if
that would be still appropriate for stage3.

There are still other cases that aren't folded:
static_assert (a.e + 1 > a.e, "");
static_assert (a.e < a.e + 1, "");
static_assert (a.e + 2 > a.e, "");
static_assert (a.e < a.e + 2, "");

static_assert (a.e != 0, "");
static_assert (a.e + 1 != 0, "");
static_assert (a.e + 2 != 0, "");

(only the a.e != 0 case is folded).


More information about the Gcc-bugs mailing list