Should expressions of uninstantiated template type trigger misc-redundant-expression when compared with !=?

In e.g.:

template <typename T> bool foo(T a) { return a != a; } 

Should we be emitting a misc-redundant-expression here? This is valid code when T is instantiated as a floating point type (for nan checking).

Is this working as intended or should this actually not be raising this diagnostic?

See also: [clang-tidy] misc-redundant-expression warns on templated check for NaN · Issue #92178 · llvm/llvm-project · GitHub

CC: @ayzhao @aeubanks

The right place to address this is in the issue you pointed to, if it has not been updated in a while then it is appropriate to ping the issue.

Hi, I think when foo is instantiated only with float it should not warn, but if foo is instantiated with int,float, etc.. it is a valid warnings

I’m sorry that it takes long to proceed: we have far more bugs/edge cases that we can fix. If the check is not too old, may be good to ping the original author in case he wants to maintain/improve the check.