From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,7e35f49d4d9340ab X-Google-Attributes: gidfc89c,public X-Google-Thread: 109fba,7e35f49d4d9340ab X-Google-Attributes: gid109fba,public X-Google-Thread: 1164f8,7e35f49d4d9340ab X-Google-Attributes: gid1164f8,public 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 Message-ID: #1/1 X-Deja-AN: 331384107 Content-Transfer-Encoding: 8bit Sender: dag-erli@grjottunagard.ifi.uio.no References: <34FF7719.41C6@ned.dem.csiro.au> Content-Type: text/plain; charset="iso-8859-1" Organization: Gutteklubben Terrasse / KRST / PUMS X-url: http://www.stud.ifi.uio.no/~dag-erli/ Newsgroups: comp.sys.dec,comp.lang.c++,comp.unix.programmer Andrew Ellerton 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)