https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116404
Bug ID: 116404
Summary: nodiscard is not warned on casts (non void)
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
[[nodiscard]] int f(); /* { dg-message "declared here" } */
void g() {
(unsigned int)f(); /* { dg-warning "ignoring return value of " } */
}
```
I had assumed this would warn but currently GCC does not.
Both MSVC and clang warn here too.