Issue 208647
Summary [compiler-rt][tysan][libc++] False positives with std::variant
Labels
Assignees
Reporter onurcan-isler-oss
    # `std::variant`
#### Flags: `-stdlib=libc++ -fsanitize=type -O0`
#### Compiler: x86-64 clang 22.1.0
#### Link: https://godbolt.org/z/11xdacM4x
#### Code: 
```.cpp
#include <variant>

int main() {
  std::variant<int, double> v;
  v = 1;
  v = 3.5;
  return 0;
}
```
#### Logs:
```
==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x7ffc76b4b8d8 (pc 0x5f1c6fa72e8c bp 0x7ffc76b4b610 sp 0x7ffc76b4b5a0 tid 1)
WRITE of size 8 at 0x7ffc76b4b8d8 with type double (in std::__1::__variant_detail::__alt<1ul, double> at offset 0) accesses an existing object of type int (in std::__1::__variant_detail::__alt<0ul, int> at offset 0)
    #0 0x5f1c6fa72e8b  (/app/output.s+0x39e8b)
```
#### Explanation:
`v=3.5` writes a `double` over bytes still typed as the old `int`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to