bug in ultrix cc (possibly fixed now)

Tim Bray tbray at watsol.waterloo.edu
Wed Jul 4 07:46:03 AEST 1990


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).



More information about the Comp.lang.c mailing list