From: dag-erli@ifi.uio.no (Dag-Erling Coidan Sm�rgrav)
Subject: Re: Division by zero crashes on DEC should be avoidable!
Date: 1998/03/06 [thread overview]
Message-ID: <xzpd8g03t8k.fsf@grjottunagard.ifi.uio.no> (raw)
In-Reply-To: 34FF7719.41C6@ned.dem.csiro.au
Andrew Ellerton <andrewe@ned.dem.csiro.au> writes:
> However, the C++ code will crash the entire application
> on the DEC 4.0 version when it divides by zero. Is this
> solvable by (for example) compiling with a certain switch?
> Or is there any other way to stop it from crashing, or do
> I have to resort to modifying the code?
Don't do that, then.
Honestly, you're complaining that your program is crashing when you're
doing something illegal?
The OS is *doing you a favor* by sending your program a SIGFPE, which
causes it to abort and produce a coredump, which you can then use for
debugging. If the division by zero were silently ignored, you'd never
know there had been an error, and you might actuallly rely on the
(incorrect) result the program would produce. This might not be of any
significance - it might simply mean an incorrect display in, say, a
game - or it could cost lives.
And if you are really, really 100% certain that dividing by zero is
the correct behaviour for your program (in which case IMHO you need to
*seriously* rethink your design) then *catch the signal*. signal(2) is
there for a reason. Install a SIGFPE handler which notifies the user
that an illegal operation was attempted.
For more information, RTFM.
--
"I have a closed mind. It helps keeping the rain out." (Michael Press on a.s.r)
next prev parent reply other threads:[~1998-03-06 5:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-03-06 5:00 Division by zero crashes on DEC should be avoidable! Andrew Ellerton
1998-03-06 5:00 ` Ron Natalie
1998-03-06 5:00 ` Daniel S. Riley
1998-03-06 5:00 ` mathog
1998-03-06 5:00 ` Michael C. Grant
1998-03-06 5:00 ` Pierre Asselin
1998-03-08 5:00 ` Michael C. Grant
1998-03-06 5:00 ` Dag-Erling Coidan Sm�rgrav [this message]
1998-03-06 5:00 ` John Wilson
1998-03-06 5:00 ` Michael C. Grant
1998-03-06 5:00 ` Jeffrey J. Potoff
1998-03-09 5:00 ` Dan A. Mercer
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox