[comp.sys.hp] HP9000 C-Compiler Bug

jv@mhres.mh.nl (Johan Vromans) (07/20/88)

Recently I ran into two serious bug in the HP9000 C-compiler. Both of
them involve the casting of relational expressions involving doubles.

Background: HP9000 model 320, HP-UX 5.3. I know - it's not the most
	recent version of HPUX.

Problem 1: the C-compiler can not handle the assignment of a cast of 
	a relational expression involving doubles.

Repeat-By:
	main () {
		double d1, d2, d3;
		d1 = (double)(d2 < d3);
	}

Symptoms: the C-compiler dies with
	"compiler error: no table entry for op =".

Remark: this happens for all relational operators:
	==, !=, <, >, <=, and >= .

Problem 2: wrong code is generated when a relational expression
	involving doubles is cast to double, and passed as an argument to 
	a function.

Repeat-By:
	main () {
		double d2, d3;
		sub((double)(d2 < d3));
	}

	which results in the following (relevant piece of) code:

		fmov.d	-8(%a6),%fp0	d2 -> fp.reg.0
		fcmp.d	%fp0,-16(%a6)	compare with d3
		fbnlt.l	L13		branch
		movq	&1,%d0		'true' result
		bra.l	L14
	L13:
		movq	&0,%d0		'false' result
	L14:
		mov.l	%d0,-(%sp)	<<< PUSH ONE LONGWORD (4 bytes)
		jsr	_sub		call sub
		addq	&6,%sp		<<< REDUCE STACK w/ 6 BYTES

	Only one (long)word is pushed on the stack when 'sub' is called.
	After return from the subroutine, 6 bytes are popped,
	resulting in stack-corruption. In other situations, the number of
	bytes differ, e.g. "sub(d1,(double)(d2 < d3))" pushes 12 but
	pops 16 bytes.

Symptoms: random core dumps.

Remark: this seems to occur with all relational operators.

Hope this is usefull ....
-- 
	Johan

mev@hpfcdc.HP.COM (Mike Vermeulen) (07/21/88)

I checked the program examples on more recent compilers.  Both problems were
fixed in the 5.5 release (and following releases).

--mev