From owner-freebsd-hackers Thu Dec 23 14:46:59 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from monkeys.com (i180.value.net [206.14.136.180]) by hub.freebsd.org (Postfix) with ESMTP id 3BE1A14C28 for ; Thu, 23 Dec 1999 14:46:56 -0800 (PST) (envelope-from rfg@monkeys.com) Received: from monkeys.com (localhost [127.0.0.1]) by monkeys.com (8.9.3/8.9.3) with ESMTP id OAA03248; Thu, 23 Dec 1999 14:46:27 -0800 (PST) To: Sheldon Hearn Cc: David Malone , hackers@FreeBSD.ORG Subject: Re: SIGFPE on arithmetic overflow In-reply-to: Your message of Thu, 23 Dec 1999 22:05:15 +0200. <59403.945979515@axl.noc.iafrica.com> Date: Thu, 23 Dec 1999 14:46:27 -0800 Message-ID: <3246.945989187@monkeys.com> From: "Ronald F. Guilmette" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <59403.945979515@axl.noc.iafrica.com>, you wrote: > > >On Thu, 23 Dec 1999 17:14:55 GMT, David Malone wrote: > >> Try adding a fpsetmask(fpgetmask()&(~FP_X_OFL)); before the calculation >> and see what happens. > >It still bombs, although fpsetmask(0) does the trick. I'm really >interested in hearing what causes the difference in behaviour. Sorry, I breezed past the first part of this thread too quickly, so I forgot which OS is doing what. However let me say that I do still have a copy of the IEEE floating point standard around here, and if anybody needs me to, I'll be happy to look stuff up in it, and/or to cite chapter and verse. The bottom line, I think, is that the IEEE FP standard talks about two things of interest here... exceptions and traps. An exception is just some condition that probably only arises infrequently (e.g. overflow, divide by zero, and other such stuff). An exception may or may not cause a trap. A trap is one possible response to an exception, and can be thought of as being essentially the same sort of thing as a (non-blocked) UNIX signal. Anyway, to bring this back to the topic at hand, the relevant quote from IEEE Std 754-1985 (Section 7, paragraph 1) is: ``The default response to an exception shall be to proceed without a trap.'' In other words, for a conforming implementation of IEEE 754, unless you explicitly override the default behavior (e.g. with a call to fpsetmask) exceptions (including FP overflow) SHOULD NOT cause a trap. I should say however that back when I was doing compiler testing for a living... a few eons ago... this was something that a lot of implementa- tions did seem to screw up.... Many compiler/library/OS combinations would invoke main() with one or more of the IEEE FP exceptions set to cause a trap/signal (in violation of IEEE 754). To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message