https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116194
Bug ID: 116194 Summary: enhancement: attribute to protect tagged unions Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: uecker at gcc dot gnu.org Target Milestone: --- An attribute that can be attached to tagged unions that traps when a non-active field is accesses. One option may be a generic attribute that specifies a condition that needs to be fulfilled on access of a field. struct { enum { A, B } tag; union { int a [[guard(.tag == A)]]; float b [[guard(.tag == B]]; }; };