This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Autoconf manual's coverage of signed integer overflow & portability
- From: Paul Eggert <eggert at CS dot UCLA dot EDU>
- To: gcc at gcc dot gnu dot org, autoconf at gnu dot org, bug-gnulib at gnu dot org, autoconf-patches at gnu dot org
- Date: Tue, 02 Jan 2007 22:45:27 -0800
- Subject: Re: Autoconf manual's coverage of signed integer overflow & portability
- References: <200701030509.l03593Rq020525@localhost.localdomain>
Andrew Pinski <pinskia@physics.uc.edu> writes:
> Let me make the point that signed overflow has been undefined since
> before the C standard was finialized and in fact there is a nice
> paper/book called "C Traps and Pitfalls[2]" which mentions all of this
> back in 1988.
C Traps and Pitfalls, like K&Rv2, is derived from a draft of the C89
standard and was intended to match the final C89 standard closely. It
is therefore not a reliable source of information about traditional C.
K&Rv1 is a better source, and as David Daney reports in
<http://gcc.gnu.org/ml/gcc/2006-12/msg00948.html>
it said that integer overflow handling was machine-dependent
and that all existing implementations ignored overflows.
This corresponds to existing practice at the time,
which was that signed overflow wrapped; but clearly
there was an attempt to allow other implementations.
Compiler writers have been trying to drag C users away from C's
traditional wrapping semantics ever since C89 came out, but they
haven't been all that succesful yet.