[libcxx-commits] [libcxx] [libc++] Applied `[[nodiscard]]` to `<exception>`, `<stdexcept>` and `<system_error>` (PR #170837)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 24 01:14:22 PST 2025
================
@@ -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
----------------
frederick-vs-ja wrote:
Was it really intended to guard these cases while using <code>-D_LIBCPP_ENABLE_*MEOW*</code>?
https://github.com/llvm/llvm-project/pull/170837
More information about the libcxx-commits
mailing list