[Bug middle-end/81172] Improve -Warray-bounds for address arithmetic

2017-06-29 Thread ryxi at stu dot xidian.edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81172

--- Comment #2 from Xi Ruoyao  ---
(In reply to Andrew Pinski from comment #1)
> The first one is well defined by C/C++.

[expr.add] para 4:

When an expression that has integral type is added to or subtracted
from a pointer, the result has the type of the pointer operand. If
the expression P points to element x[i] of an array object x with n
elements, the expressions P + J and J + P (where J has the value j)
point to the (possibly-hypothetical) element x[i + j] if 0 ≤ i + j ≤
n; otherwise, the behavior is undefined. Likewise, the expression P -
J points to the (possibly-hypothetical) element x[i − j] if 0 ≤ i
− j ≤ n; otherwise, the behavior is undefined.

[Bug middle-end/81172] Improve -Warray-bounds for address arithmetic

2017-06-22 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81172

--- Comment #1 from Andrew Pinski  ---
The first one is well defined by C/C++.