You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to https://eel.is/c++draft/class.union#general-6 , the active union member in an union of non-POD types can be switched by invoking the dtor of the old member, and placement new-ing into the new member.
==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x7ffff9117e2c (pc 0x61eed1b9b89d bp 0x7ffff9117d10 sp 0x7ffff9117cb8 tid 1)
WRITE of size 4 at 0x7ffff9117e2c with type int (in Bar at offset 0) accesses an existing object of type short (in Foo at offset 0)
#0 0x61eed1b9b89c (/app/output.s+0x2b89c)
This also happens with an union of POD or trivial types, but I'm not 100% sure on the standard wording if placement-new is supposed to be allowed in these cases.
The text was updated successfully, but these errors were encountered:
According to https://eel.is/c++draft/class.union#general-6 , the active union member in an union of non-POD types can be switched by invoking the dtor of the old member, and placement new-ing into the new member.
However, tysan does not seem to like this https://godbolt.org/z/nvnjzjGez
This also happens with an union of POD or trivial types, but I'm not 100% sure on the standard wording if placement-new is supposed to be allowed in these cases.
The text was updated successfully, but these errors were encountered: