[m-rev.] for discussion: undefined behaviours in int.m
Peter Wang
novalazy at gmail.com
Fri Oct 21 18:42:03 AEDT 2016
On Fri, 21 Oct 2016 17:53:29 +1100, Peter Wang <novalazy at gmail.com> wrote:
>
> We'd need to use unsigned integer operations to get _defined_ overflow
> behaviour, or rely on compiler switches like gcc -fwrapv or gcc
> -fno-strict-overflow. Otherwise, the C compiler can assume that signed
> integer overflow does not happen, and generate code accordingly.
Actually -fno-strict-overflow doesn't _define_ signed integer overflow;
-fwrapv does.
Note that UndefinedBehaviorSanitizer won't report that an operation
overflowed if the overflow is defined (see the name). That's a shame if
you consider an overflow to be a likely indicator of a bug.
Peter
More information about the reviews
mailing list