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

            Bug ID: 113252
           Summary: No -Wtype-limits on comparaisons against type max
                    values
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mailhol.vincent at wanadoo dot fr
  Target Milestone: ---

Let ui be an unsigned int, then expression

  ui > UINT_MAX

is a tautology (always false).

However gcc's -Wtype-limits does not catch the above. However, it will emit a
warning for:

  ui > (unsigned long)UINT_MAX

Both expression get optimized out at compilation time, so it is surprising not
to get a warning for both.

This affects all GCC versions.

Follow this link for above example in actions:

  https://godbolt.org/z/MWaMao5Tr


Yours sincerely,
Vincent Mailhol
  • [Bug c/113252] New: No -Wty... mailhol.vincent at wanadoo dot fr via Gcc-bugs

Reply via email to