auto-increment bug in Ultrix(4.1) C (DS3100)
Mumit Khan
khan at pslu1.psl.wisc.edu
Mon Apr 1 07:41:27 AEST 1991
---------------- MIPS C bug in post-increment of variables ----------
MACHINE = DS3100
OS = ULTRIX V4.1 (Rev. 52) System #1: Wed Dec 19 15:20:46 CST 1990
UWS V4.1 (Rev. 197)
Note the output from the following program in various cases. MIPS C is
the only one causing the problem (of not incrementing the global shared
variable "pc" in the call (*(*pc++))().
------------------------ START OF PROGRAM ---------------------------
#include <stdio.h>
typedef int (*Inst)();
#define StopInst (Inst) 0
static int dummy ();
static Inst machine[] = {dummy, dummy, dummy, dummy, dummy, StopInst};
static Inst *pc = NULL;
main () {
extern int start;
fprintf (stderr, "Starting pc: %x\n", pc = machine);
for (; *pc != StopInst;)
(*(*pc++)) (); /* BUG BUG BUG BUG BUG BUG BUG */
}
static int dummy () {
extern Inst *pc;
fprintf (stderr, "PC (in dummy): %x\n", pc);
return 0;
}
------------------------- END OF PROGRAM ------------------------
OUTPUT FROM MIPS CC. (Version 2.1)
> bug-mips-cc
Starting pc: 10000430
PC (in dummy): 10000430 <--- NOTE *NO* INCREMENT
PC (in dummy): 10000434
PC (in dummy): 10000438
PC (in dummy): 1000043c
PC (in dummy): 10000440
OUTPUT FROM MIPS GCC. (Version 2.1)
> gcc -v
gcc version 1.37.1 OSF 1.9.2.14 Ultrix Dec Mips Dec 29 1990
> bug-mips-gcc
Starting pc: 10000460
PC (in dummy): 10000464 <--- NOTE INCREMENT
PC (in dummy): 10000468
PC (in dummy): 1000046c
PC (in dummy): 10000470
PC (in dummy): 10000474
OUTPUT FROM SparcStation (IPC) CC. (SunOS rel. 4.1.1)
> bug-sun4-cc
Starting pc: 40a8
PC (in dummy): 40ac <--- NOTE INCREMENT
PC (in dummy): 40b0
PC (in dummy): 40b4
PC (in dummy): 40b8
PC (in dummy): 40bc
---------------------------------------------------------------------
More information about the Comp.unix.ultrix
mailing list