https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92230
Bug ID: 92230 Summary: Proposal to have builtin underflow detection function Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: arieltorti14 at gmail dot com Target Milestone: --- Right now GCC provides `__builtin_sub_overflow` to check for overflows during subtraction, but there's not way to check for underflow, other than maybe comparing the operators beforehand. Maybe it would be a good idea to have `__builtin_sub_underflow` functions which could be optimized at a greater level by reading the flags instead of doing integer comparisons. As a side note, is the behavior of `__builtin_sub_overflow` the intended one ?