Xref: utzoo unix-pc.bugs:76 comp.sys.att:5503 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!xanth!uunet!bsadrc!carver From: carver@bsadrc.UUCP (Darrel R. Carver) Newsgroups: unix-pc.bugs,comp.sys.att Subject: UNIX-PC Floating point weirdness Message-ID: <129@bsadrc.UUCP> Date: 10 Feb 89 06:13:45 GMT Reply-To: carver@bsadrc.UUCP (Darrel R. Carver) Distribution: na Organization: CommTek Publishing Company Lines: 52 I have been having some strange problems with floating point expressions in the UNIX-PC C compiler. I am using the 3.51 development set. The problem seems to occur when using *complex* expressions involving floating point numbers. Consider the following example: 1 >| #include 2 >| 3 >| struct RVAL { 4 >| double ret_val; 5 >| /* Other elements */ 6 >| }; 7 >| 8 >| struct RVAL rval; 9 >| 10>| float fbug(f_return) 11>| struct RVAL *f_return; 12>| { 13>| float a, b, c; 14>| 15>| a = b = c = 0.0; 16>| 17>| /* Some processing involving a, b, c */ 18>| return(f_return->ret_val = a); 19>| } 20>| 21>| main() 22>| { 23>| fbug(&rval); 24>| } Now, compiling this program (call it ftest), I get this error: >>>| $ cc -o ftest ftest.c >>>| "ftest.c", line 18: compiler error: allocation fails, op STAR If I change line 18 to 18>| f_return->ret_val = a; 18x| return(a); It compiles, no problem. I do not consider the second form acceptable. In addition some of the code I have from various sources will do the type of assignments in the example. I can usually go around this by breaking down the subexpression, but it is annoying. Any comments? flames? -- Darrel R Carver - A clever quote goes here. Have we got any in CommTek Publishing Company - the unquotable quotes? Vienna, Va 22180 - uunet!bsadrc!carver - Mr. Bear