https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92227
Bug ID: 92227 Summary: Optimizations on constant integer overflow checks lead to incorrect results Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: arieltorti14 at gmail dot com Target Milestone: --- Created attachment 47113 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47113&action=edit PoC generator When `fold_builtin_arith_overflow` optimizes the overflow check on integer constants it never sets the overflow flag on the flag register leading to incorrect results. Attached is a file containing two versions of a program showcasing the bug.