https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125682
Bug ID: 125682
Summary: nodiscard class does not warn for statement expression
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: diagnostic, stmt-expr
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
struct [[nodiscard]] MyNodiscardInt {
int x;
};
MyNodiscardInt my_func() {
return MyNodiscardInt{ 0 };
}
#define MY_MACRO() \
({ my_func(); })
int f() {
MY_MACRO();
return 0;
}
```
I would have expected a warning for stmt expression since the result is
discarded.