llvm / llvm/llvm-project

[Clang][CodeGen] UBSan fails to detect misaligned memory access after PR152575

Open
#177,682 1 comment 0 reactions 1 assignee Claimed by @dtcxzyw View on GitHub
clang:codegen compiler-rt:ubsan regression:22
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

With https://github.com/llvm/llvm-project/pull/152575, the pointer alignment of a subscript expression gets refined based on the constant indices. It may cause a smaller alignment than the natural one. Now ubsan no longer detects misaligned memory access in some cases. We want to make ubsan stricter to restore the previous behavior.

Reproducers (credits to @vitalybuka):
before: https://godbolt.org/z/E1rG51cc1
after: https://godbolt.org/z/rj47nMbno
gcc: https://godbolt.org/z/hxbaPhTrM

See also https://github.com/llvm/llvm-project/pull/152575#issuecomment-3649041011 and https://github.com/llvm/llvm-project/issues/177064 for previous discussions.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.