================
@@ -168,6 +171,33 @@ void testFunctionalCastWithInitExpr(unsigned a) {
   unsigned c = unsigned{0};
 }
 
+void testBinaryOperatorRedundantCasting() {
+  const auto diff_types_operands1 { static_cast<float>(1.0f + 1) };
----------------
vbvictor wrote:

I have a mixed feeling about such diagnostics.
It could be quite useful if you have:
```cpp
float bigFunctionRetursSomething();

int main() {
    // compiler-determined return type; could be complex lambda
    auto l = [] () { return bigFunctionRetursSomething(); };
    auto l2 = ....
    // a lot of lines

    // you don't know exactly what will l and l2 will return (could be 
something different than float in near future)
    auto a { static_cast<float>(l() + l2()) };

    return 0;
}
```

I'm leaning towards this becoming an option instead of hard-coded part.
We are on thin ice with this one. I can imagine a regression report where we 
flagged a "valid case" as redundant.

https://github.com/llvm/llvm-project/pull/191386
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to