compiler detecting divide by zero

Al Dunbar userAKDU at mts.ucs.UAlberta.CA
Thu Nov 29 13:26:23 AEST 1990


In article <36233 at cup.portal.com>, ts at cup.portal.com (Tim W Smith) writes:
>For obscure reasons that I won't go into, I wanted a divide
>by zero in a program.  I was compiling on SCO Unix System V/386
>relase 2.2 (I think...) with whatever C compiler comes with
>this version of Unix.
>
>I tried the obvious:
>
>        int     i, j;
>
>        i = 1;
>        j = 0;
>        i/=j;
>
>The compiler caught this.  Grrr.  Next I tried:
 
I was curious about how my compiler would handle these
attempts (QC 2.51), so I tried it, and it caught them
all! Next I tried:
 
scanf( "%d %d", i, j );
i/=j
 
Would you believe it caught this too ("Warning: user may
accidentally enter invalid input resulting in a runtime
divide exception")?
 
 
 
 
 
I didn't think so :-)
 
-------------------+-------------------------------------------
Al Dunbar          |
Edmonton, Alberta  |  "this mind left intentionally blank"
CANADA             |          - Manuel Writer
-------------------+-------------------------------------------
#! r



More information about the Comp.lang.c mailing list