Open
Description
Consider:
#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.