Title
[[maybe_unused]] and structured bindings
Status
cd5
Section
9.12.8 [dcl.attr.unused]
Submitter
Michael Wong

Created on 2017-10-19.00:00:00 last changed 40 months ago

Messages

Date: 2018-11-15.00:00:00

Proposed resolution (November, 2018):

Change 9.12.8 [dcl.attr.unused] paragraphs 2 and 3 as follows:

The attribute may be applied to the declaration of a class, a typedef-name, a variable (including a structured binding declaration), a non-static data member, a function, an enumeration, or an enumerator.

[Note: For an entity marked maybe_unused, implementations should not emit a warning that the entity is or its structured bindings (if any) are used or unused. , or that the entity is used despite the presence of the attribute. —end note] For a structured binding declaration not marked maybe_unused, implementations should not emit such a warning unless all of its structured bindings are unused.

Date: 2018-10-15.00:00:00

Notes from the October, 2018 teleconference:

CWG agreed that such an annotation should be permitted and apply to the underlying variable; i.e., a compiler might warn in the absence of such an attribute if none of the structured bindings were used, and the presence of the attribute would silence such warnings.

Date: 2019-02-15.00:00:00

[Accepted as a DR at the February, 2019 meeting.]

According to9.12.8 [dcl.attr.unused] paragraph 2,

The attribute may be applied to the declaration of a class, a typedef-name, a variable, a non-static data member, a function, an enumeration, or an enumerator.

This does not include structured bindings, although there seems to be no good reason to prohibit uses like

  [[maybe_unused]] auto [a, b] = std::make_pair(42, 0.23);
History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6403
2020-12-15 00:00:00adminsetmessages: + msg6402
2020-12-15 00:00:00adminsetstatus: open -> cd5
2017-10-19 00:00:00admincreate