[compiler-rt][tysan][libc++] False positives with std::array element access
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
# `std::array`
#### Flags: `-stdlib=libc++ -fsanitize=type -O0` or `-stdlib=libc++ -fsanitize=type -O1`
#### Compiler: x86-64 clang 22.1.0
#### Link: https://godbolt.org/z/WjrWeP37G
#### Code:
```.cpp
#include
std::array a;
int main() {
a[0] = 1;
}
```
#### Logs:
```
==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x61c8a6194ee4 (pc 0x61c8a583af84 bp 0x7ffcc1fa7320 sp 0x7ffcc1fa72b0 tid 1)
WRITE of size 4 at 0x61c8a6194ee4 with type int accesses an existing object of type std::__1::array
#0 0x61c8a583af83 (/app/output.s+0x35f83)
```
#### Explanation:
libc++ `std::array` is likely firing due to wrapper vs raw element storage
Contributor guide
Research direction
Reproduce the report using the shown std::array example with libc++, clang 22.1.0, and -fsanitize=type at -O0 or -O1; the Godbolt link is provided for comparison. Investigate how libc++ std::array element access is represented to TypeSanitizer versus its raw element storage. Done means the access no longer produces a false type-aliasing violation and the behavior is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100