rsmith added a comment.

In D85778#2251160 <https://reviews.llvm.org/D85778#2251160>, @zequanwu wrote:

> Hi, this change seems like hits a false positive case in chromium build: 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1124085

That's not a false positive. The code is (simplified):

  int RoundDown(int a, long b) { return a & -b; }

... which is implicitly converting an expression of type `long` to `int`, 
losing precision. For example, `RoundDown(-1, 0x1'0000'0000)` is -4294967296 
prior to the implicit conversion from `long` to `int`. Given that the 
truncation is presumably intentional (0 at least seems like the least-bad 
answer for rounding down 0 to a multiple of 2^32 as a 32-bit integer), you can 
suppress the warning with a cast.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85778/new/

https://reviews.llvm.org/D85778

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D85778: M... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D857... Nikita Popov via Phabricator via cfe-commits
    • [PATCH] D857... Zequan Wu via Phabricator via cfe-commits
    • [PATCH] D857... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D857... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D857... Zequan Wu via Phabricator via cfe-commits

Reply via email to