-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Open
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negativeWarning doesn't fire when it shouldWarning doesn't fire when it should
Description
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
llvm-project/libcxx/include/complex
Line 784 in 979462c
| operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { |
llvm-project/libcxx/include/complex
Line 817 in 979462c
| operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { |
template <typename T>
void test() {
const std::complex<T> c;
const std::complex<T> d;
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}}
}frederick-vs-ja
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negativeWarning doesn't fire when it shouldWarning doesn't fire when it should