https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100161
Bug ID: 100161 Summary: Impossible to suppress Wtype-limits warning involving template parameter. Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yyc1992 at gmail dot com Target Milestone: --- If a comparison involving a template parameter is always true or false, it should not raise a warning if it could take other values for other template parameters. In particular, the type-limits warning from the code below, ``` void f(unsigned); template<unsigned n> void g() { for (unsigned i = 0; i < n; i++) { f(i); } } void h() { g<0>(); } ``` seems to be impossible to suppress. I think this is a regression around GCC 9 time. (I remember seeing it roughly around the same time/slightly after https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90728) This is partially related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95148 (which would at least provide a way to suppress the warning). Also somewhat related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81642 though supposedly the C++ template example given there is fixed.