[libcxx-commits] [libcxx] [libc++][ios] Applied `[[nodiscard]]` (PR #173520)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 26 04:56:14 PST 2025


================
@@ -575,43 +575,43 @@ public:
 #    ifdef _LIBCPP_CXX03_LANG
   // Preserve the ability to compare with literal 0,
   // and implicitly convert to bool, but not implicitly convert to int.
-  _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
+  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
 #    else
-  _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
+  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
----------------
frederick-vs-ja wrote:

Reverting in #173658. I wonder whether you implied that there shouldn't even be diagnostic message for such contrived misuse.

https://github.com/llvm/llvm-project/pull/173520


More information about the libcxx-commits mailing list