Issue |
141791
|
Summary |
[clang] [[nodiscard]] ignored in std::function due to warning suppression in system headers
|
Labels |
clang
|
Assignees |
|
Reporter |
avikivity
|
Consider:
```c++
#include <functional>
struct [[nodiscard]] A {};
A f();
std::function<void ()> ff(f);
void g() {
ff();
}
```
std::function calls f() (or rather, a function pointer that that returns an A), but returns void. So somewhere, something should complain about the nodiscard A being discarded. But it looks like it's explicitly silenced somewhere, causing hard-to-find bugs.
Investigation by the gcc team [1] revealed it's likely due to -Wunused-result being suppressed in system headers, which it probably should not be.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120460
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs