Issue 83433
Summary [clang-tidy] False positive bugprone-implicit-widening-of-multiplication-result when multiplying literals
Labels clang-tidy
Assignees
Reporter chrchr-github
    ~~~c++
long long f() {
    return 1 * 2 * 3LL;
}
~~~
~~~
<source>:2:12: warning: performing an implicit widening conversion to type 'long long' of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
    2 |     return 1 * 2 * 3LL;
      |            ^
<source>:2:12: note: make conversion explicit to silence this warning
    1 | long long f() {
    2 | return 1 * 2 * 3LL;
      |            ^~~~~
      | static_cast<long long>( )
<source>:2:12: note: perform multiplication in a wider type
    2 |     return 1 * 2 * 3LL;
      |            ^
 |            static_cast<long long>( )
~~~
Clearly there is no danger of overflow here. Also, the suggested fix of adding a `static_cast` on a literal is rather silly.
https://godbolt.org/z/vjhzEqMKc
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to