[clang] [clang] add array out-of-bounds access constraints using llvm.assume (PR #159046)

Sebastian Pop via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 4 15:55:21 PDT 2025


sebpop wrote:

> I would be carful exploiting this kind of information, possibly protect is with a compiler switch in the tradition of -fstrict-aliasing.

[702d9dd](https://github.com/llvm/llvm-project/pull/159046/commits/702d9dd71e4a646077e5d3347f36a43807dcec4a) adds a flag -fassume-array-bounds disabled by default for now.

> How does your change interact with sanitizers?

[702d9dd](https://github.com/llvm/llvm-project/pull/159046/commits/702d9dd71e4a646077e5d3347f36a43807dcec4a) disables assume generation when sanitizer array-bounds is on.

> I wouldn't be surprised if some code out there does purposeful access to memory past the array, even though it's UB.

[702d9dd](https://github.com/llvm/llvm-project/pull/159046/commits/702d9dd71e4a646077e5d3347f36a43807dcec4a) detects struct with last field a flexible size array.




https://github.com/llvm/llvm-project/pull/159046


More information about the cfe-commits mailing list