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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D158338:... Félix-Antoine Constantin via Phabricator via cfe-commits
    • [PATCH] D15... Félix-Antoine Constantin via Phabricator via cfe-commits
    • [PATCH] D15... Piotr Zegar via Phabricator via cfe-commits
    • [PATCH] D15... Piotr Zegar via Phabricator via cfe-commits
    • [PATCH] D15... Félix-Antoine Constantin via Phabricator via cfe-commits
    • [PATCH] D15... Piotr Zegar via Phabricator via cfe-commits

Reply via email to