Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ames!sparkyfs.erg.sri.com!hercules!fernwood!portal!cup.portal.com!ts From: ts@cup.portal.com (Tim W Smith) Newsgroups: comp.lang.c Subject: compiler detecting divide by zero Message-ID: <36233@cup.portal.com> Date: 26 Nov 90 10:46:48 GMT Organization: The Portal System (TM) Lines: 44 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 = 1; j = 1; i -= 1; j/=i; It still caught it. Double grrr! Next try: int i, j, *p; i = 1; j = 1; p = &i; j /= *p - 1; It still caught it! This one got past it: j = 5; for ( i = 0; i < 5; i++ ) j--; i /= j; After the previous try, I was a bit surprised that it didn't figure out this one! Tim Smith