[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

Shivam Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 23 11:46:29 PDT 2023


xgupta added a comment.

In D155457#4523227 <https://reviews.llvm.org/D155457#4523227>, @aaron.ballman wrote:

> In D155457#4513812 <https://reviews.llvm.org/D155457#4513812>, @xgupta wrote:
>
>> In D155457#4511652 <https://reviews.llvm.org/D155457#4511652>, @aaron.ballman wrote:
>>
>>> In the x86 compilation: `sizeof(std::size_t) < sizeof(uint64_t)` is true, so we test the other expression; because `Size` is greater than `__SIZE_MAX__` the function returns false and the second static assertion fails as expected.
>>> In the x64 compilation: `sizeof(std::size_t) < sizeof(uint64_t)` is false (first static assertion fails) so we shouldn't even be evaluating the RHS of the `&&` to see if it's tautological because it can't contribute to the expression result, right?
>>
>> Yes, I agree with both statements but what is odd in current behavior?
>
> It's a false positive -- the tautological bit is diagnosed but it doesn't contribute to the result of the expression. The first part of the predicate is specifically intended to ensure the second part of the predicate is *not* tautological.

Ok, Is there any modification required in this patch or it fixes that false positive?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457



More information about the cfe-commits mailing list