[Bug c++/85973] [[nodiscard]] on class shall emit a warning for unused anonymous variable

2024-02-29 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85973

Marek Polacek  changed:

   What|Removed |Added

 CC||tiagomacarios at gmail dot com

--- Comment #4 from Marek Polacek  ---
*** Bug 98520 has been marked as a duplicate of this bug. ***

[Bug c++/85973] [[nodiscard]] on class shall emit a warning for unused anonymous variable

2023-03-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85973

Andrew Pinski  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  ---
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.