🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4620

Re: Undefined result vs. int's holding undefined values.

#4620
From: Nick Maclaren
Date: Fri, 12 Jan 1996 13:52
40 lines
2286 bytes
In article <DL2CFs.FG0@harlequin.co.uk>, daveb@harlqn.co.uk (Dave Berry) writes:
|> baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes:
|> >Daniel Wood (dwood@informix.com) wrote:
|> >: Do any machines exist which actually explode when you add two number together
|> >: such that the result would exceed MAXINT? :-)  Get practical!
|> >
|> >VAXes
|> >If you set the apropriate bit in the process status word then integer overflow
|> >causes a trap.
|> 
|> The SPARC and MIPS processors also have integer instructions that trap on
|> overflow.

Not to say the IBM 370 and numerous others.  In any case, it isn't
difficult to compile in reasonably efficient software checks.  But,
as others have pointed out, that isn't the issue.

Most compilers (whether C, Fortran or other) do not generate code
that will trigger the trap.  On the IBM 370, several of them did
so more by accident than design, and so would trap on addition but
not multiplication!  Even those that did it 'properly' often left
it out of conversions and I/O.

Some systems have a process flag that triggers whether integer
overflow causes an exception or not.  Write a bit of assembler
that flips that bit and trying running a few programs - you will
probably find that valid array indexing fails or the run-time
system dies horribly (e.g. in I/O conversion).

I would like this feature very much, but I don't expect to see it
come back into most Fortran systems, let alone C ones!  But the
standard definitely allows it (for signed values and many or most
conversions).


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679
Technical Details
Message-ID: <4d5p2k$p6d@lyra.csx.cam.ac.uk>
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
References: <4ck70b$rd7@news.informix.com> <oZA8wQ9ytpjN084yn@csn.net> <4cs460$d6e@news.informix.com> <DKyIx1.1qr@ukpsshp1.serigate.philips.nl> <DL2CFs.FG0@harlequin.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.std.c
Subject: Re: Undefined result vs. int's holding undefined values.
Date: 12 Jan 1996 13:52:20 GMT
Organization: University of Cambridge, England
Message-ID: <4d5p2k$p6d@lyra.csx.cam.ac.uk>
References: <4ck70b$rd7@news.informix.com> <oZA8wQ9ytpjN084yn@csn.net> <4cs460$d6e@news.informix.com> <DKyIx1.1qr@ukpsshp1.serigate.philips.nl> <DL2CFs.FG0@harlequin.co.uk>
NNTP-Posting-Host: ursa.cus.cam.ac.uk