https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88680

            Bug ID: 88680
           Summary: [9 Regression] bogus -Wtype-limits for constant
                    expressions after r267272
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

-Wtype-limits is documented to

    Warn if a comparison is always true or always false due to the limited
range of the data type, but do not warn for constant expressions. 

According to the documentation the following test case should be accepted with
no warning, but since r267272 triggers one (Clang does not warn):

$ cat t.C && gcc -S -Wtype-limits t.C
const unsigned n = 8;

static_assert (n >= 0 && n % 2 == 0, "");
t.C:3:18: warning: comparison of unsigned expression >= 0 is always true
[-Wtype-limits]
    3 | static_assert (n >= 0 && n % 2 == 0, "");
      |                ~~^~~~

This change apparently causes a large number of new warnings in Firefox builds.
 According to my breakdown of Honza's build here at the following link, there
are over 20 thousand such warnings:
https://hg.mozilla.org/try/rev/e1e0472c3f68e47b9741d7814ef4417759cde24c

Diagnostic                        Count   Unique    Files
-Wtype-limits                     20882    10441      604
-Wmultistatement-macros            1552        5        2
-Wcoverage-mismatch                 793      225      141
-Wclass-memaccess                   346       72       46
-Wsign-compare                      292      127       55
-Wnarrowing                         272        2        1
-Wmissing-profile                   245      212      207
-Wattributes                        212        1        1
-Wint-in-bool-context               140        3        2
-Wdeprecated-copy                   104       22       10
-Wmaybe-uninitialized               103       67       54

Reply via email to