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