https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90691
Bug ID: 90691 Summary: [GCC9 regression] -Wsign-compare false-positive with constant Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lebedev.ri at gmail dot com Target Milestone: --- Manually reduced: #include <cstdint> struct S { int a; constexpr S(); explicit constexpr S(int a_) : a(a_) {} }; constexpr S b = S(12); template <const S& e> bool c(unsigned int d) { return d >= e.a; } bool test(unsigned int d); bool test(unsigned int d) { return c<b>(d); } GCC diagnoses: <source>: In instantiation of 'bool c(unsigned int) [with const S& e = b]': <source>:19:18: required from here <source>:14:12: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'const int' [-Wsign-compare] 14 | return d >= e.a; | ~~^~~~~~ Compiler returned: 0 clang doesn't. https://godbolt.org/z/7xrWzz But there can't ever be any issues here, the signed 'int a' is '12', which is known-positive. Indeed, if the constant is negative, clang warns: https://godbolt.org/z/yQBXB8