- 论坛徽章:
- 0
|
If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined. If the result points one past the last element of the array object, it shall not be used as the operand of a unary * operator that is evaluated.
上面说的是 P + N 情况。这里 P 是指针,N 是整数。上文翻译如下:
如果指针操作数(P)和结果(P + N)都指向同一数组对象的元素或者(不是数组元素的)次数组对象最后一个元素的下一个位置,(对 P + N 的)求值不应产生溢出;否则,其行为是未定义的。如果结果(P + N)指向数组对象最后一个元素的下一个位置,它不应该用作用来进行求值的单目运算符 * 的操作数。
----------------------------------------
(The behavior is undefined in the following circumstances:)
— Addition or subtraction of a pointer into, or just beyond, an array object and an
integer type produces a result that does not point into, or just beyond, the same array
object (6.5.6).
翻译如下:
(下列情况属于未定义行为:)
— 如果一个指针指向数组对象或者数组对象最后一个元素的下一个位置,而对此指针加上或者减去一个整数类型产生的结果既不指向同一数组数组对象,也不指向(同一数组对象的)最后一个元素的下一个位置 |
|