Better HN
topnewbestaskshowjobs
Log inSign up

lilllly

8 karma · joined Nov 28, 2022 (3y ago) · 2 submissions

Submissions

comment 3y ago · link · parent

I can easily test if n+1 is < n with fwrapv.

Without you have to do convoluted things like rearranging the expression to unnatural forms (move the addition to the right but invert to subtraction, etc), special case INT_MAX/INT_MIN, and so on - which you then have to hope the compiler is smart enough to optimize, which it often isn't (oh how ironic).

comment 3y ago · link · parent

We need a -fsane-c

Then they can add a #pragma optimize(assumes=no-int-overflow, whatever, etc) to precisely add optimizations when needed and you 'know' its safe.