https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org --- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Richi, did you mean something like this? With this we wouldn't warn on nor p - (p - 1); neither q - (q - 1); line... --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -3513,6 +3513,9 @@ pointer_diff (location_t loc, tree op0, tree op1) { lit0 = TREE_OPERAND (con0, 1); con0 = TREE_OPERAND (con0, 0); + lit0 = convert (inttype, lit0); + if (TREE_CODE (lit0) == INTEGER_CST) + TREE_OVERFLOW (lit0) = 0; } else lit0 = integer_zero_node; @@ -3521,6 +3524,9 @@ pointer_diff (location_t loc, tree op0, tree op1) { lit1 = TREE_OPERAND (con1, 1); con1 = TREE_OPERAND (con1, 0); + lit1 = convert (inttype, lit1); + if (TREE_CODE (lit1) == INTEGER_CST) + TREE_OVERFLOW (lit1) = 0; } else lit1 = integer_zero_node;