Issue 52806
Summary bugprone-implicit-widening-of-multiplication-result improvements
Labels clang-tidy
Assignees
Reporter chfast
    This is nice check, but it is also triggered for a multiplication of only constants.
```
long x = 1 * 1;
long y = 4 * 1024;
```
I think the check should ignore such situation. I assume there is a compiler warning if the constant multiplication result is out-of-range of the destination type.

Moreover, the suggested warning suppression is `static_cast<long>(4 * 1024)`. However a variant of this `long{4 * 1024}` does not suppress the warning.

I believe the better way would be to use the actual type of the multiplication: `int{4 * 1024}`. This actually works as the warning suppression.

https://godbolt.org/z/Y1xYn988e
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to