[PATCH] D158338: [clang-tidy] [bugprone-implicit-widenin g-of-multiplication-result]Improved check to ignore false positives with integer literals.
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 19 11:27:22 PDT 2023
PiotrZSL added a comment.
I'm not sure if this is right fix, example:
const std::size_t k1Tb = 1024 * 1024 * 1024 * 1024;
This is detected by -Winteger-overflow, but this:
const std::size_t k1Pb = 1024U * 1024U * 1024U * 1024U * 1024U;
is not detect by anything except this check, even that it overflow to 0.
Funny thing that if we change those unsigned to signed, then its detected by -Winteger-overflow
For me we shoudn't silent those issues, if someone want they they can always put nolint or explicit cast, we could consider adding some basic calculations just to verify if there will be no overflow, but still proper way would be to provide warning that would say, hey, write this as: "1024LU * 1024LU"
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158338/new/
https://reviews.llvm.org/D158338
More information about the cfe-commits
mailing list