Description
Full name of submitter: Brian Bi
Reference (section label): [dcl.attr.nodiscard]
Issue description: According to the current wording, a call to a [[nodiscard]]
function with void return type is still considered a nodiscard call and the recommended practice is to issue a warning unless the call is explicitly cast to void
. Casting to void
is pointless in that case and no implementation encourages it. This may arise in the case of function templates with dependent return type.
Suggested resolution: Edit [dcl.attr.nodiscard]/4:
Recommended practice: Appearance of a nodiscard call as a potentially-evaluated discarded-value expression ([expr.prop]) of non-void type is discouraged unless explicitly cast to
void
. Implementations should issue a warning in such cases. [...]
Note: We don't need to say cv void
, because there are no expressions of qualified void
type. https://eel.is/c++draft/expr.type#2