Warnings for partially-unused structured bindings in C++26 mode
Project / Subsystem
gcc / gcc
Date
2026-05-12
Proposer
Ionuț Nicula <nicula@nicula.xyz>
Source type
public_inbox
Consensus
Proposed
Sentiment
—/10
Technical tradeoffs
- • Requires C++26 mode to avoid being unergonomic.
- • May increase the number of warnings, requiring developers to add `_` placeholders.
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- discussion_id
- IwntDp_Q1VxRwhn7aMzNxnY2SVNNCEI8BMw2bMGfoymG74jx1ONjefmAtoNwjrkk2xcpHC7nBhKor_UBDinXr4qGnWi5pbKCkaK4G1RRzfQ=@nicula.xyz
- source_type
- public_inbox
- title
- Warnings for partially-unused structured bindings in C++26 mode
- headline
- Propose warnings for partially-unused structured bindings in C++26.
- tldr
- In C++26, enable `-Wunused` warnings for unused variables in structured bindings, now that unnamed placeholders are available.
- proposer
- Ionuț Nicula <nicula@nicula.xyz>
- consensus
- Proposed
- outcome
- proposed
- sentiment_score
- —
- technical_tradeoffs
-
- • Requires C++26 mode to avoid being unergonomic.
- • May increase the number of warnings, requiring developers to add `_` placeholders.
- series_id
- —
- series_role
- standalone
- series_parts
- []
- tags
-
- • gcc
- • c++
- • warnings
- • structured bindings
- • unused variables
- bugzilla_url
- —
- date
- 2026-05-12T00:00:00.000Z
Warnings for partially-unused structured bindings in C++26 mode
Ionuț Nicula proposes enabling -Wunused warnings for structured bindings in C++26 mode when some sub-objects are unused. Before C++26, the lack of a placeholder variable (like _) made this awkward. This change could catch errors, particularly in loops where a variable is unintentionally unused due to copy-paste mistakes.