https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71448
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I wrote so far --- fold-const.c.jj1 2016-06-06 19:39:40.000000000 +0200 +++ fold-const.c 2016-06-08 09:56:56.830326277 +0200 @@ -8527,9 +8527,9 @@ fold_comparison (location_t loc, enum tr if ((offset0 == offset1 || (offset0 && offset1 && operand_equal_p (offset0, offset1, 0))) - && (code == EQ_EXPR - || code == NE_EXPR - || (indirect_base0 && DECL_P (base0)) + && (equality_code + || (indirect_base0 + && (DECL_P (base0) || TREE_CODE (base0) == STRING_CST)) || POINTER_TYPE_OVERFLOW_UNDEFINED)) { @@ -8568,7 +8568,9 @@ fold_comparison (location_t loc, enum tr 6.5.6/8 and /9 with respect to the signed ptrdiff_t. */ else if (bitpos0 == bitpos1 && (equality_code - || (indirect_base0 && DECL_P (base0)) + || (indirect_base0 + && (DECL_P (base0) + || TREE_CODE (base0) == STRING_CST)) || POINTER_TYPE_OVERFLOW_UNDEFINED)) { /* By converting to signed sizetype we cover middle-end pointer for this which works fine, but you're right CONSTANT_CLASS_P (base0) might be better.