[comp.lang.c] bug in ultrix cc

tbray@watsol.waterloo.edu (Tim Bray) (07/04/90)

The following little fragment illustrates (I think) a horrible bug in ultrix
v2 cc.  OK, OK, I'm upgrading to ultrix v3 tomorrow, but for those still at
v2, and in the horrible eventuality that v3 doesn't fix this, her it is:

typedef struct 
{
  int	garbage;
  int	parameter;
} t;

main()
{
  t *pt;

  pt = (t*) malloc(sizeof(t));
  pt->parameter = -2;

  printf("%d\n", -6 * pt->parameter);
}

The bug is that the code prints -12, not 12.  It seems to have to do with
dereferencing structure members & multiplying by negative literals in
an arg list.  I dumped the .s code but don't know mips assembler well
enough to figure out what's up (it looks like jal (which is a macro?) is
doing something wrong).

ryan@decuac.dec.com (Paul Ryan) (07/09/90)

	Works under Ultrix 3.1 on RISC.  It's pretty amazing that you are running
	2.0 on a mips machine since mips support started with 3.0.

	paul ryan
	ryan@decuac.dec.com