https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88301
Bug ID: 88301 Summary: Optimization regression with undefined unsigned overflow Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pskocik at gmail dot com Target Milestone: --- I noticed gcc 7.* did a really nice optimization that allowed me to communicate I want even some unsigned overflows to be undefined: #define ADD_NW(A,B) (__extension__({ __typeof(A+B) R; if(__builtin_add_overflow(A,B,&R)) __builtin_unreachable(); R ;})) _Bool a_b(unsigned A, unsigned B) { return A+B >= B; } _Bool a_b2(unsigned A, unsigned B) { return ADD_NW(A,B) >= B; } resulted in: a_b: add edi, esi setnc al ret a_b2: mov eax, 1 ret But on gcc 8.* it's a_b: add edi, esi setnc al ret a_b2: add edi, esi setnc al ret again.