| Issue |
171031
|
| Summary |
[clang] Annotating `operator*` and `operator/` with `[[nodiscard]]` does not produce a diagnostic message
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
H-G-Hristov
|
While annotating `<complex>` with `[[nodiscard]]` I stumbled upon that annotating the overloads bellow with `[[nodiscard]]` does not produce the expected diagnostic in Clang 22 but it does in GCC 15. See: https://github.com/llvm/llvm-project/actions/runs/20003026692
https://github.com/llvm/llvm-project/blob/979462c876c96c3023c0b5e42c8eda88323fd745/libcxx/include/complex#L784
https://github.com/llvm/llvm-project/blob/979462c876c96c3023c0b5e42c8eda88323fd745/libcxx/include/complex#L817
```C++
c* d; // NOT OK
c* T(1); // expected-warning 3 {{ignoring return value of function declared with 'nodiscard' attribute}}
T(1) * c; // expected-warning 3 {{ignoring return value of function declared with 'nodiscard' attribute}}
c / d; // NOT OK
c / T(1); // expected-warning 3 {{ignoring return value of function declared with 'nodiscard' attribute}}
T(1) / c; // expected-warning 3 {{ignoring return value of function declared with 'nodiscard' attribute}}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs