Created on 2024-10-24.00:00:00 last changed 3 weeks ago
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.
(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 }
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-02-14 17:08:12 | admin | set | status: tentatively ready -> ready |
2025-02-02 20:32:21 | admin | set | status: open -> tentatively ready |
2024-10-26 20:39:24 | admin | set | messages: + msg7861 |
2024-10-24 00:00:00 | admin | create |