[libcxx-commits] [libcxx] [libcxx] Poison memory in variant destroy (PR #101048)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 29 07:08:52 PDT 2024


philnik777 wrote:

> I don't think there is a destructor to call in this case as the type is trivial, so I didn't think that it was semantically correct to call the dtor in this case, unless you think it's appropriate even for the trivial case (although I'd be happy to try that if that's your preference). The destructor for the `_Trait::_Available` case below does call the underlying object's destructor, and MSAN understands that.

There is no destructor to call, but it's perfectly valid to call a destructor on such types: https://godbolt.org/z/qWjzvPYjW. It's called a pseudo-destructor for these cases. I think this would be a better alternative, since it avoids any MSan-specific code and makes it clear to any tooling that the lifetime of the object has ended.


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


More information about the libcxx-commits mailing list