================
@@ -87,4 +89,15 @@ void test() {
   std::ranges::unique(iter, iter); // expected-warning {{ignoring return value 
of function declared with 'nodiscard' attribute}}
   std::ranges::upper_bound(range, 1); // expected-warning {{ignoring return 
value of function declared with 'nodiscard' attribute}}
   std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring 
return value of function declared with 'nodiscard' attribute}}
+
+#if TEST_STD_VER >= 23
+  std::ranges::fold_left(range, 0, std::plus());
+  // expected-warning@-1{{ignoring return value of function declared with 
'nodiscard' attribute}}
----------------
cjdb wrote:

I think it's substantially better to be explicit about wanting to discard the 
result, since the primary function of this algorithm is to return a computed 
result. I also expect the common case to be to want the result, rather than not.

```cpp
(void)std::ranges::fold_left(r, 0, side_effect_f); // clearly discarding the 
result
```

https://github.com/llvm/llvm-project/pull/75259
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to