[LLVMbugs] [Bug 11382] Pointer comparison failure with opt -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 16 00:18:01 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=11382

seb <babslachem at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #6 from seb <babslachem at gmail.com> 2011-11-16 02:18:01 CST ---
Sorry, reading C standard I don't understand your statement about undefined
behavior could you please elaborate before marking problem as resolved ?
Here is what I read in the document:

When an expression that has integer type is added to or subtracted from a
pointer, the
result has the type of the pointer operand. If the pointer operand points to an
element of
an array object, and the array is large enough, the result points to an element
offset from
the original element such that the difference of the subscripts of the
resulting and original
array elements equals the integer expression. In other words, if the expression
P points to
the i-th element of an array object, the expressions (P)+N (equivalently,
N+(P)) and
(P)-N (where N has the value n) point to, respectively, the i+n-th and i−n-th
elements of
the array object, provided they exist. Moreover, if the expression P points to
the last
element of an array object, the expression (P)+1 points one past the last
element of the
array object, and if the expression Q points one past the last element of an
array object,
the expression (Q)-1 points to the last element of the array object. 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.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list