🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4579

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

#4579
From: Paul Eggert
Date: Sat, 06 Jan 1996 18:45
18 lines
1285 bytes
This reminds me of a similar bug I found a long time ago when porting
the Modula-3 runtime, which contained code that acted something like this:

	int sum_overflow (int x, int y) {
		return (x + y < x) != (y < 0);
	}

The C Standard does not guarantee that the above function works,
since integer overflow leads to undefined behavior,
but when I found that the function did not work with whatever old version
of GCC I was using at the time, I reported it as a bug to the GCC maintainers
and got a fix from them in a few days.

Regardless of what the C Standard says, it should be obvious that it's
crucial to have integer overflow checking working properly in an
application that needs it.  If you can't convince SCO that their
implementation's behavior is wrong, then my advice is to switch to a
better supplier.  I've heard that GCC works with SCO....
Technical Details
Message-ID: <4cmg0s$1mb@der.twinsun.com>
Path: arc1-ca.pugleaf.net!news.cs.ucla.edu!twinsun!not-for-mail
References: <4ck70b$rd7@news.informix.com> <4ckms5$rd7@news.informix.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.cs.ucla.edu!twinsun!not-for-mail
From: eggert@twinsun.com (Paul Eggert)
Newsgroups: comp.std.c
Subject: Re: Undefined result vs. int's holding undefined values.
Date: 6 Jan 1996 10:45:48 -0800
Organization: Twin Sun Inc, El Segundo, CA, USA
Message-ID: <4cmg0s$1mb@der.twinsun.com>
References: <4ck70b$rd7@news.informix.com> <4ckms5$rd7@news.informix.com>
NNTP-Posting-Host: der.twinsun.com