]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* doc/autoconf.texi (Integer Overflow):
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 3 May 2006 01:08:27 +0000 (01:08 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 3 May 2006 01:08:27 +0000 (01:08 +0000)
Mention the special case of integer division overflow.

ChangeLog
doc/autoconf.texi

index 051ac1ccf44643a67cbc50763a420d38c418fae5..78716f6ecd9b5f8288194c4a9a9e417259e03e43 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,15 @@
 2006-05-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        * doc/autoconf.texi: Use @option systematically.
+       (Integer Overflow):
 
 2006-05-02  Paul Eggert  <eggert@cs.ucla.edu>
        and Bruno Haible  <bruno@clisp.org>
 
        * doc/autoconf.texi (Limitations of Usual Tools): Add a paragraph
        about 'od'.
+       (Integer Overflow): Mention the special case of integer division
+       overflow.
 
 2006-05-02  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
index 5795813b942b74c67c9911d2bc78d34aa0e3d984..4996f05c529edcda522e610ffdb6bb20462a6b35 100644 (file)
@@ -14267,17 +14267,23 @@ the programs work well enough in practice.
 @cindex overflow, arithmetic
 
 In C, signed integer overflow leads to undefined behavior.  However,
-many programs and Autoconf tests assume that integer overflow silently
-wraps around modulo a power of 2 so long as you cast the resulting value
+many programs and Autoconf tests assume that signed integer overflow after
+addition, subtraction, or multiplication silently
+wraps around modulo a power of two, using two's complement arithmetic,
+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
+are portable to the vast majority of modern platforms.  However, signed
+integer division is not always harmless: for example, on CPUs of the
+i386 family, dividing @code{INT_MIN} by @code{-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.
+the rare platforms where signed integer overflow does not wrap around
+after addition, subtraction, or multiplication.
 
-In contrast, unsigned integer overflow reliably wraps around modulo the
-word size.
+Unsigned integer overflow reliably wraps around modulo the word size.
+This is guaranteed by the C standard and is portable in practice.
 
 @node Null Pointers
 @section Properties of Null Pointers