https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95148
Bug ID: 95148 Summary: -Wtype-limits always-false warning triggered despite comparison being avoided Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eyalroz at technion dot ac.il Target Milestone: --- Consider the following program: #include <type_traits> int main() { unsigned x { 5 }; return (std::is_signed<decltype(x)>::value and (x < 0)) ? 1 : 0; } when compiling it with GCC versions 11.0 20200511, 10.1, 9.2.1, 8.3.0, I get the warning: a.cpp:5:52: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] I should not be getting this warning, because when x is unsigned, the comparison is never performed, due to the short-circuit semantics of `and`. This can be easily determined by the compiler - and probably is. No less importantly, the author of such a line in a program clearly specified his/her intent here with this check. clang doesn't seem to issue a warn inf does come to pass.