386/ix bug on doubles inside if-statement ?

dirk dirk at altger.UUCP
Tue Apr 26 02:10:33 AEST 1988


Does anyboady have an idea why the following program fails ?

It seems as the compiler can not handle functions which return
a double inside an 'if' statement. I've tested it under the
Interactive UNIX Sys. V rel. 3 v. 1.0.3 port to the iAPX386
and Microport's version 2.1. Both failed. Only the Silicon
Valley IN80386 'C' compiler works fine, thus the bug can not
be in the libraries.

A workaround is to use dummy variables inside the if statement.

cu,
dirk :-)

..unido!cosa!dirk
%%
#include <math.h>

main()
{
	double	a, b, bugI, bugII;

	a= -3.1415;
	b= 0.00001;
	printf ("|a|= %lf\n", fabs (a));
	printf ("|b|= %lf\n", fabs (b));
	if (fabs (a) < fabs (b))
		printf ("1. a is lower\n");
	if ((bugI= fabs (a)) < (bugII= fabs (b)))
		printf ("2. a is lower\n");
	printf ("3. %c is lower\n", fabs (a) < fabs (b)?'a':'b');
}	
%%



More information about the Comp.unix.microport mailing list