<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66570>66570</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] bugprone-unused-return-value shouldn't encourage to suppress issue with casting to void
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiotrZSL
</td>
</tr>
</table>
<pre>
Example:
```
#include <vector>
#include <algorithm>
void test()
{
std::vector<int> a;
std::remove_if(a.begin(), a.end(), [](int v) { return v > 5; });
}
```
This generate warnings:
```
[<source>:7:5: warning: the value returned by this function should be used [bugprone-unused-return-value]]
7 | std::remove_if(a.begin(), a.end(), [](int v) { return v > 5; });
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[<source>:7:5: note: cast the expression to void to silence this warning]
1 warning generated.
```
Clang-tidy provide // NOLINT as an option to silent a warning, and casting to `void` shouldn't be suggested by default.
Best would be to add option `AllowSuppressionWithVoid` to the check and set it by default to `false`.
Developers treat Clang-tidy fix suggestions straight forward, in this case developer that were fixing this issue simply added `(void)`.
Message should also say that return value of this function is important, not just a code-smell.
Maybe: ```the value returned by this function should not be disregarded; neglecting it may lead to errors```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VV-r47YT_TTKy5DgSLEdP-Qhf-6FH-zur7BLC30psjWxtVUkI42Tm5d-9iLZTm7Ldksp1ATHsqQ5Z86csWQIurWIO5YfWH5ayIE653c_aEf-588fFrVT993Lm7z0BpnYs-zEsj0rsuk3DrnQtjGDQmDieMWGnGfi5VuT0rTOa-ouz_l0vzqtgDAQ41vGq2mqPIwPEEhFcLGfgx-1JSZeQDIxrwF4LvN4cVf8RZ8Z38pVja22U2B-BLlCq57DMXHGt9oSXBmvgJUH8EiDt3CFiJIzcQBWnuKOGS8O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