This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-02-14
(From submission #628.)
A warning is currently, but ought not to be, encouraged for a call to a [[nodiscard]] function with a void return type. Such a situation may arise for dependent return types. For example:
[[nodiscard]] void f(); template<class T> [[nodiscard]] T g(); void h() { f(); // suggested change: warning no longer recommended (void)f(); // warning not recommended g<int>(); // warning recommended g<void>(); // suggested change: warning no longer recommended (void)g<void>(); // warning not recommended }
Proposed resolution (2025-01-21, approved by CWG 2025-02-14):
Change in 9.12.10 [dcl.attr.nodiscard] paragraph 4 as follows:
Recommended practice: Appearance of a nodiscard call as a potentially-evaluated discarded-value expression (7.2 [expr.prop]) of non-void type is discouraged unless explicitly cast to void. Implementations should issue a warning in such cases. The value of a has-attribute-expression for the nodiscard attribute should be 0 unless the implementation can issue such warnings.