[libcxx-commits] [libcxx] [libc++] Applied `[[nodiscard]]` to `<exception>`, `<stdexcept>` and `<system_error>` (PR #170837)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 6 09:26:15 PST 2026
================
@@ -81,11 +84,47 @@ void test() {
}
#endif
+ { // <exception>
+ {
+ std::bad_exception bex;
+
+ bex.what(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::exception ex;
+
+ ex.what(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::nested_exception nex;
+
+ nex.nested_ptr(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+
+#if TEST_STD_VER <= 14
----------------
Zingam wrote:
Yes. But after the discussion I think we can remove these and add a comment instead that these are functions are removed. I hope won't forget about that.
https://github.com/llvm/llvm-project/pull/170837
More information about the libcxx-commits
mailing list