10 Declarations [dcl.dcl]

10.6 Attributes [dcl.attr]

10.6.6 Maybe unused attribute [dcl.attr.unused]

The attribute-token maybe_­unused indicates that a name or entity is possibly intentionally unused. It shall appear at most once in each attribute-list and no attribute-argument-clause shall be present.

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.

[Note: For an entity marked maybe_­unused, implementations are encouraged not to emit a warning that the entity is unused, or that the entity is used despite the presence of the attribute. end note]

A name or entity declared without the maybe_­unused attribute can later be redeclared with the attribute and vice versa. An entity is considered marked after the first declaration that marks it.

[Example:

[[maybe_unused]] void f([[maybe_unused]] bool thing1,
                        [[maybe_unused]] bool thing2) {
  [[maybe_unused]] bool b = thing1 && thing2;
  assert(b);
}

Implementations are encouraged not to warn that b is unused, whether or not NDEBUG is defined. end example]