Signed overflow optimization hazards in the kernel
Signed overflow optimization hazards in the kernel
Posted Aug 17, 2012 21:57 UTC (Fri) by pdewacht (subscriber, #47633)In reply to: Signed overflow optimization hazards in the kernel by wahern
Parent article: Signed overflow optimization hazards in the kernel
But given that Linux is only intended to be compiled by gcc, we can rely on its implementation-defined behavior:
The result of, or the signal raised by, converting an integer to a signed integer type when the value cannot be represented in an object of that type (C90 6.2.1.2, C99 6.3.1.3).For conversion to a type of width N, the value is reduced modulo 2^N to be within range of the type; no signal is raised.
(and I don't see how any compiler for a two's complement computer could define different behavior.)
