Hi Paul,
Here's a patch to correct the slightly wrong statement that "integer overflow
silently wraps around ... the vast majority of modern platforms".
The special case of signed division overflow is rarely relevant in practice,
but it's instructive to know that even on modern platforms, integer arithmetic
can lead to a fatal signal.
2006-05-01 Bruno Haible <[EMAIL PROTECTED]>
* doc/autoconf.texi (Integer Overflow): Mention the special case of
integer division overflow.
--- autoconf.texi.bak 2006-05-01 22:15:21.000000000 +0200
+++ autoconf.texi 2006-05-01 23:09:41.000000000 +0200
@@ -14217,14 +14217,18 @@
@cindex overflow, arithmetic
In C, signed integer overflow leads to undefined behavior. However,
-many programs and Autoconf tests assume that integer overflow silently
+many programs and Autoconf tests assume that integer overflow in all
+arithmetic operations except division silently
wraps around modulo a power of 2 so long as you cast the resulting value
to an integer type or store it into an integer variable. Such programs
are portable to the vast majority of modern platforms. C99 has a way of
specifying this portability (the LIA-1 option) but this is not
-universally supported yet. GCC users might consider using the
[EMAIL PROTECTED] option if they are worried about porting their code to
-the rare platforms where overflow does not wrap around.
+universally supported yet. Integer overflow during signed integer division,
+on the other hand, is not harmless: On CPUs of the i386 family, division
[EMAIL PROTECTED] / -1} yields a SIGFPE signal which by default terminates the
+program. GCC users might consider using the @option{-ftrapv} option if
+they are worried about porting their code to the rare platforms where
+overflow does not wrap around.
In contrast, unsigned integer overflow reliably wraps around modulo the
word size.