From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,d821ae0e1a95c270,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1993-12-30 09:37:41 PST Path: gmd.de!xlink.net!howland.reston.ans.net!spool.mu.edu!news.clark.edu!netnews.nwnet.net!news.u.washington.edu!mcygnus From: mcygnus@u.washington.edu (Marc Cygnus) Newsgroups: comp.unix.osf.osf1 Subject: OSF1.3 alpha cc bug? (unexplained SIGFPE: HELP!) Date: 30 Dec 1993 17:33:13 GMT Organization: Human Interface Technology Laboratory Distribution: usa Message-ID: <2fv3cp$ogj@news.u.washington.edu> NNTP-Posting-Host: stein.u.washington.edu I skimmed the group and didn't see anything about this (apologies in advance if it's old news, but I'm about to go out of my skull)... On a DEC 3500 (Alpha), OSF 1.3, I get FPEs at bizarre times in the code below. The code opens a binary file of floats (longword) which is just a big rectangular array; it scans through the entire file looking for minimum and maximum values. It's not efficient, it's meant to illustrate the bug. ============================== #include #include main() { float fV, fMin, fMax; int i, j; int fd; fd = open( "/big/huge/data/file", O_RDONLY ); fMin = 10000.0; fMax = -10000.0; for ( j = 0; j < 3992; j++ ) { for ( i = 0; i < 1728; i++ ) { read( fd, &fV, 4 ); printf( "(%d,%d) = %.2f\n", i, j, fV ); /* line 20 */ if ( fV > fMax ) fMax = fV; /* line 23 */ else if ( fV < fMin ) fMin = fV; } } printf( "min,max = %.4f, %.4f\n", fMin, fMax ); } ============================== Now the fun begins: % cc -float bug.c -o bug % bug (0,0) = 0.00 /* correct first value, incidentally */ Floating exception % dbx bug dbx version 3.11.1 ... (dbx) run (0,0) = 0.00 signal Floating point exception at [main:23 +0x4,0x120001214] fMax = fV; It gets the signal always at line 23 in this case. Hmm... let's try: % cc -g -float bug.c -o bug % bug Floating exception /* uh-oh, didn't print... ?? */ % dbx bug ... (dbx) run signal Floating point exception at [printf:92 ,0x3ff800a2410] ... (dbx) where 0 printf(...)... 1 main() ["bug.c":20, 0x1200011f8] Now it gets the signal always at line 20. *grrrrrr* If I comment out lines 22--25 (the if/else/if block), the program runs fine if compiled with "-float" and no debugging; if compiled "-g -float", it crashes as before (as one would expect, I suppose). If you have ANY CLUE what's going on here, PLEEEEEASE enlighten me. I don't have all of the most recent OSF release notes, so I don't know if this is known behavior. I've tried at least twenty-three variations... pointers, runtime casting, temporary variables, block reads, other operations besides ">"... I've tried looking at the assembly. I can't find a workaround. This is a *major* problem for me because of the number of hours I've put in and the amount of work this damned thing is holding up. Help! -Marc W. Cygnus cygnus@hitl.washington.edu