UNIX-PC Floating point weirdness

Darrel R. Carver carver at bsadrc.UUCP
Fri Feb 10 16:13:45 AEST 1989


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 <stdio.h>
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



More information about the Comp.sys.att mailing list