https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85973
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-03-21 Ever confirmed|0 |1 Summary|[[nodiscard]] shall emit a |[[nodiscard]] on class |warning for unused |shall emit a warning for |anonymous variable |unused anonymous variable Status|UNCONFIRMED |NEW --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Reduced testcase: ``` struct [[nodiscard]] scope_exit { scope_exit(int); }; int main() { scope_exit{0}; } ``` Note if we move the attribute to the constructor, then GCC will error out.