Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mimsy!umd5!virginia!krebs!wrp From: wrp@krebs.acc.virginia.edu (Wm Pearson) Newsgroups: comp.unix.xenix Subject: SCO Xenix 'C' pointer bug Message-ID: <227@krebs.acc.virginia.edu> Date: Tue, 25-Aug-87 15:20:15 EDT Article-I.D.: krebs.227 Posted: Tue Aug 25 15:20:15 1987 Date-Received: Thu, 27-Aug-87 06:24:19 EDT Organization: School of Medicine, University of Va. Lines: 37 Attached is a test program which displays a bug I just found in the SCO 'C' development system 2.1.4 release G. Compile the program and run it. You will find the value of 'dpos' goes up to 3999 just fine, but then becomes negative. I would appreciate a work-around that does not require a division by sizeof(struct tstruct). Note that although the pointers are being treated as ints (intead of unsigned) in the expression (int)(dptr-diag), they are being treated properly in the 'dptr<&diag[5000]. ============= test.c Bill Pearson wrp@virginia.BITNET ...!seismo!virginia!wrp #include struct tstruct { int one; int two; int three; int four; } *diag, *dptr; main() { char *calloc(); unsigned int dpos; diag = (struct tstruct *)calloc(5000,sizeof(struct tstruct)); for (dptr=&diag[99]; dptr<&diag[5000]; dptr +=100) { dpos = (unsigned int)(dptr-diag); printf("%4d %4d\n",dpos,(int)(dptr-diag)); } } =============