Warning | ||
---|---|---|
| ||
This rule is an incomplete work in progress. It is intended as a future replacement of the following rules all of which cover related material: |
Using pointer arithmetic such that the result does not point into or just past the end of the same object, using such pointers in arithmetic expressions, or dereferencing pointers that do not point to a valid object in memory results in potentially exploitable undefined behavior and must be avoided.
...
UB | Description | |||
---|---|---|---|---|
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. | ||||
Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that points just beyond the array object and is used as the operand of a unary | ||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f42cde5378c9cc56-4fe403a0-4f654ebf-8d11a564-bec21ce71eafe2e863d3bc6a"><ac:plain-text-body><![CDATA[ | [46 | CC. Undefined Behavior#ub_46] | An array subscript is out of range, even if an object is apparently accessible with the given subscript (as in the lvalue expression | ]]></ac:plain-text-body></ac:structured-macro> |
An attempt is made to access, or generate a pointer to just past, a flexible array member of a structure when the referenced object provides no elements for that array. |
...