https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120460
Bug ID: 120460 Summary: std::function ignores [[nodiscard]] attribute Product: gcc Version: 15.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: avi at scylladb dot com Target Milestone: --- 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.