GCC's -Wtype-limits (part of -Wextra):
Warn if a comparison is always true or always false due to the limited range of the data type
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
clang/include/clang/Basic/DiagnosticGroups.td | ||
---|---|---|
485 ↗ | (On Diff #188957) | Is gcc's -Wtype-limits *just* -Wtautological-constant-in-range-compare, or is something else should be there? |
clang/include/clang/Basic/DiagnosticGroups.td | ||
---|---|---|
485 ↗ | (On Diff #188957) | -Wtautological-constant-in-range-compare is enough to diagnose 99% cases from: One missed case is: if ((long long)x <= 0x123456789ABCLL) return 1; else return 0; } Tried -Weverything, no help. We miss this case. I will open PR for that. But anyway, this missed case should not block this patch. |
clang/include/clang/Basic/DiagnosticGroups.td | ||
---|---|---|
485 ↗ | (On Diff #188957) |
That doesn't really answer the question. |
clang/include/clang/Basic/DiagnosticGroups.td | ||
---|---|---|
485 ↗ | (On Diff #188957) | Yes, silences it correctly. |
I worry a little bit about our -Wtype-limits getting out of sync from GCC's due to making it a synonym for -Wtautological-constant-in-range-compare, but I'm also at a loss for why these two should ever have different functionality.
I think I'm okay with this, but I'd like @rsmith to weigh in as well.
clang/include/clang/Basic/DiagnosticGroups.td | ||
---|---|---|
485 ↗ | (On Diff #188957) | Thoughts about why we behave differently here: https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/gcc/testsuite/g%2B%2B.dg/warn/Wtype-limits2.C |
xbolva00 abandoned this revision.
Do you not want to pursue this any more?
This seems reasonable to me, and is in line with other cases where we have diagnostic flags as aliases to GCC's similar-but-not-quite-the-same flags (eg, GCC's -Wnoexcept-type doesn't fire in quite the same set of cases as clang's -Wc++17-compat-mangling, but we alias them; likewise for GCC -Wsequence-point versus Clang -Wunsequenced).
Ok, reclaiming patch.
Thanks for the review! If the patch is fine, please approve it.