[PATCH] D39149: [libc++] Prevent tautological comparisons
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 13:16:20 PDT 2017
lebedev.ri added a comment.
In https://reviews.llvm.org/D39149#911024, @rsmith wrote:
> In https://reviews.llvm.org/D39149#910936, @smeenai wrote:
>
> > I'm thinking you could account for all possible type sizes in the existing (enabled by default) warning, and have a different warning for possibly tautological comparisons. E.g. if a `long` is being compared against `INT_MAX`, you know that's only tautological on some platforms, so it should go under `-Wpossible-tautological-constant-compare` (which would only be enabled by `-Weverything` and not `-Wall` or `-Wextra`); `-Wtautological-constant-compare` should be reserved for definitely tautological cases.
>
>
> This sounds like a very promising direction. (
> That is: if the types of the values being compared are different, but are of the same size, then suppress the warning or move it to a different warning group that's not part of `-Wtautological-compare`.
Ok, now **that** makes at least //some// sense :)
> ) That would also suppress warnings for cases like 'ch > CHAR_MAX', when `ch` is a `char`, but we could detect and re-enable the warning for such cases by, say, always warning if the constant side is an integer literal.
https://reviews.llvm.org/D39149
More information about the cfe-commits
mailing list