public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113252] New: No -Wtype-limits on comparaisons against type max values
@ 2024-01-06 10:59 mailhol.vincent at wanadoo dot fr
  2024-01-06 12:59 ` [Bug c/113252] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: mailhol.vincent at wanadoo dot fr @ 2024-01-06 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/113252] No -Wtype-limits on comparaisons against type max values
  2024-01-06 10:59 [Bug c/113252] New: No -Wtype-limits on comparaisons against type max values mailhol.vincent at wanadoo dot fr
@ 2024-01-06 12:59 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-06 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56995
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56995&action=edit
(non-preprocessed) testcase

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-06 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-06 10:59 [Bug c/113252] New: No -Wtype-limits on comparaisons against type max values mailhol.vincent at wanadoo dot fr
2024-01-06 12:59 ` [Bug c/113252] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).