Skip to content

Commit 4fa7b55

Browse files
committed
[LangRef] Document accessing memory outside of object is UB.
1 parent 66b93da commit 4fa7b55

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

llvm/docs/LangRef.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,9 @@ heap allocation calls, and global variable definitions. Once it is allocated,
32933293
the bytes stored in the region can only be read or written through a pointer
32943294
that is :ref:`based on <pointeraliasing>` the allocation value. If a pointer
32953295
that is not based on the object tries to read or write to the object, it is
3296-
undefined behavior.
3296+
undefined behavior. Trying to read or write memory outside of an allocated
3297+
object, including accesses partially outside an allocated object, is undefined
3298+
behavior.
32973299

32983300
The following properties hold for all allocated objects:
32993301

@@ -11108,12 +11110,9 @@ operation (that is, the alignment of the memory address). It is the
1110811110
responsibility of the code emitter to ensure that the alignment information is
1110911111
correct. Overestimating the alignment results in undefined behavior.
1111011112
Underestimating the alignment may produce less efficient code. An alignment of
11111-
1 is always safe. The maximum possible alignment is ``1 << 32``. An alignment
11112-
value higher than the size of the loaded type implies memory up to the
11113-
alignment value bytes can be safely loaded without trapping in the default
11114-
address space. Access of the high bytes can interfere with debugging tools, so
11115-
should not be accessed if the function has the ``sanitize_thread`` or
11116-
``sanitize_address`` attributes.
11113+
1 is always safe. The maximum possible alignment is ``1 << 32``. Access of the
11114+
high bytes can interfere with debugging tools, so should not be accessed if the
11115+
function has the ``sanitize_thread`` or ``sanitize_address`` attributes.
1111711116

1111811117
The alignment is only optional when parsing textual IR; for in-memory IR, it is
1111911118
always present. An omitted ``align`` argument means that the operation has the

0 commit comments

Comments
 (0)