Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site rtech.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!hplabs!amdahl!rtech!daveb From: daveb@rtech.UUCP (Dave Brower) Newsgroups: net.lang.c,net.unix Subject: C Quiz: why does this SIGFPE? Message-ID: <201@rtech.UUCP> Date: Sat, 12-Apr-86 11:33:22 EST Article-I.D.: rtech.201 Posted: Sat Apr 12 11:33:22 1986 Date-Received: Sat, 19-Apr-86 04:17:11 EST Distribution: net Organization: Relational Technology Inc, Alameda CA Lines: 35 Xref: watmath net.lang.c:8611 net.unix:7656 This is a quiz. The answer will be posted in a week or so. Don't post a reply unless you need to impress your collegues. Why will this code sometimes generate SIGFPE at the indicated point? /* An example. Does nothing usefull */ int zerf( f ) float * f; { *f = 0.0; return( (int)f ); } void show( flag, i, f ) int flag, i; float f; { if(flag) printf( "i is %d\n", i ) else printf( "f is %f\n", f ) } void dynomite( flag, i ) int flag, i; { float f; if( flag ) i = zerf( &f ); else show( flag, i, f ); /* <-- SIGFPE happens here */ } -- Red: "Whadda ya got that big nose for, granny?" Wolf: "Just to HAVE, see!" {amdahl, sun, mtxinu, cbosgd}!rtech!daveb