Path: utzoo!utgpu!watserv1!watmath!att!linac!uwm.edu!wuarchive!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!mts.ucs.UAlberta.CA!Al_Dunbar From: userAKDU@mts.ucs.UAlberta.CA (Al Dunbar) Newsgroups: comp.lang.c Subject: Re: compiler detecting divide by zero Message-ID: <1966@mts.ucs.UAlberta.CA> Date: 29 Nov 90 02:26:23 GMT References: <36233@cup.portal.com> Organization: MTS Univ of Alberta Lines: 38 In article <36233@cup.portal.com>, ts@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