https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97544
Bug ID: 97544 Summary: -Wtype-limits triggered for comparison to template argument Product: gcc Version: 10.2.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: erenon2 at gmail dot com Target Milestone: --- The following code triggers -Wtype-limits: template <unsigned N> constexpr int f(unsigned i) { return (i < N) ? 0 : 1; } int main() { return f<0>(1); } On GCC 10.2 and trunk, it produces this warning: <source>: In instantiation of 'constexpr int f(unsigned int) [with unsigned int N = 0]': <source>:4:13: warning: comparison of unsigned expression in '< 0' is always false [-Wtype-limits] 4 | return (i < N) ? 0 : 1; | ~~~^~~~ On GCC 10.1, there's no warning. godbolt: https://gcc.godbolt.org/z/cqzq8P