[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall
Richard Trieu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 16:09:12 PST 2019
rtrieu added a comment.
In D69292#1747062 <https://reviews.llvm.org/D69292#1747062>, @mclow.lists wrote:
> Sorry I'm late to the party; I've been traveling for 3+ weeks.
> I would like to be reassured that the following code will not warn:
>
> `
> long foo = ...; // some calculation
> if (foo < std::numeric_limits<int>::min() || foo > std::numeric_limits<int>::max()) .....
>
>
> This is important for systems where `sizeof(int) == sizeof(long)`
The question is whether there's a warning when a value is tautologically compared with the min or max of that value's type. They fall under -Wtype-limits or -Wtautological-constant-in-range-compare. Despite the "tautological" in the name, they do not fall under -Wtautological-compare. Therefore, your example code will not get any warnings with -Wall.
I checked the clang tests and this covered by test/Sema/tautological-constant-compare.c, testing both the warnings is active only when the specific warning groups are active (the #ifdef TEST sections) and that the warnings are off for no warning flags, just -Wextra, and just -Wall.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69292/new/
https://reviews.llvm.org/D69292
More information about the cfe-commits
mailing list