Issue 104391
Summary [clang][c23] macro + non-void cast incorrectly suppresses "nodiscard" warning
Labels clang
Assignees
Reporter poconn
    clang-18 compiles the following code warning-free at `-Weverything`, but should warn because the result of `f()` is essentially discarded (aside from the cast, but it would be to void if the result was supposed to be ignorable):
```c
[[nodiscard]] int f();

void g() {
#define M (unsigned int)f()
 M;
}
```
https://godbolt.org/z/9sdcY3eof

It does correctly warn when compiling as C++ (even with the C-style cast).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to