Re: [RFC] Proposal for tagged_by attribute to describe union discriminators
Project / Subsystem
gcc / gcc
Date
2026-07-27
Proposer
Ashton Warner <drflamemontgomery@gmail.com>
Source type
public_inbox
Consensus
Proposed
Sentiment
—/10
Technical tradeoffs
- • Adds a new language extension for improved type safety.
- • Requires front-end changes to parse and interpret the attribute.
- • No runtime performance impact.
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- discussion_id
- amfnO5MFDRqr39k0@thesun
- source_type
- public_inbox
- title
- Re: [RFC] Proposal for tagged_by attribute to describe union discriminators
- headline
- Proposal for tagged_by attribute to describe union discriminators
- tldr
- Proposes a GCC attribute to explicitly link enum discriminators to union members for improved static analysis.
- proposer
- Ashton Warner <drflamemontgomery@gmail.com>
- consensus
- Proposed
- outcome
- proposed
- sentiment_score
- —
- technical_tradeoffs
-
- • Adds a new language extension for improved type safety.
- • Requires front-end changes to parse and interpret the attribute.
- • No runtime performance impact.
- series_id
- —
- series_role
- standalone
- series_parts
- []
- tags
-
- • gcc
- • attribute
- • union
- • static-analysis
- • diagnostics
- bugzilla_url
- —
- date
- 2026-07-27T00:00:00.000Z
Re: [RFC] Proposal for tagged_by attribute to describe union discriminators
Ashton Warner proposes a new GCC attribute tagged_by to associate enum discriminators with specific union members. This attribute would provide additional information for static analysis tools, enabling them to issue diagnostics when a union is accessed with an incorrect member for its current discriminator value. The attribute is explicit and does not alter runtime behavior.