You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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. [...]
jensmaurer
changed the title
[dcl.attr.nodiscard] Discarding call to nodiscard function with void return type
CWG2943 [dcl.attr.nodiscard] Discarding call to nodiscard function with void return type
Oct 26, 2024
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 tovoid
. Casting tovoid
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:
Note: We don't need to say cv
void
, because there are no expressions of qualifiedvoid
type. https://eel.is/c++draft/expr.type#2The text was updated successfully, but these errors were encountered: