[libcxx-commits] [libcxx] [libc++][docs] Update `[[nodiscard]]` coding guidelines (PR #178384)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 2 07:05:06 PST 2026


================
@@ -175,7 +165,10 @@ have a recommended practice where to put them, so libc++ applies it whenever it
   This protects programmers from assuming too much about how the internals of a function work, making code more robust
   in the presence of future optimizations.
 
-``[[nodiscard]]`` should not be applied to conversion functions because Clang already diagnoses unused cast results.
+``[[nodiscard]]`` should not be applied to functions if Clang already diagnoses unused results, such as:
----------------
philnik777 wrote:

```suggestion
``[[nodiscard]]`` should not be applied to functions if Clang already diagnoses unused results, for example:
```
Otherwise it sounds a bit like this is an exhaustive list.

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


More information about the libcxx-commits mailing list