[clang] Always emit complete debug info for types which appear as a member of a standard-layout union. (PR #221615)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 11:50:45 PDT 2026
================
@@ -3244,6 +3244,17 @@ static bool canUseCtorHoming(const CXXRecordDecl *RD) {
RD->hasConstexprNonCopyMoveConstructor())
return false;
+ // Skip this optimization if this type is standard-layout and is a member of
+ // some standard-layout union in this translation unit. Per the C++ spec, "it
+ // is permitted to inspect the common initial part of any of" the "common
+ // initial sequence" of distinct types in a standard-layout union. This
+ // exception to strict aliasing enables producing a reference to a type
+ // without ever having constructed that type.
+ //
+ // See: https://timsong-cpp.github.io/cppwp/n3337/class.mem#19
----------------
AaronBallman wrote:
```suggestion
// See: https://wg21.link/class.mem#general-30
```
https://github.com/llvm/llvm-project/pull/221615
More information about the cfe-commits
mailing list