Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!sri-spam!ames!ptsfa!ihnp4!ihnet!tjr From: tjr@ihnet.ATT.COM (Tom Roberts) Newsgroups: comp.sys.ibm.pc Subject: TURBO C Bug - huge arrays Message-ID: <563@ihnet.ATT.COM> Date: Wed, 12-Aug-87 12:09:24 EDT Article-I.D.: ihnet.563 Posted: Wed Aug 12 12:09:24 1987 Date-Received: Sat, 15-Aug-87 01:13:04 EDT Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 35 Keywords: huge arrays I have just encountered another TURBO C Bug (groan!). Consider: struct x { int id; char space[126]; } huge *x; /* sizeof(struct x) = 128 */ int n; n = 520; x = (struct x huge *)farmalloc((long)n*sizeof(struct x)); Now x[0] thru x[511] are OK, but x[512] is the same as x[0]. If I do this: struct x huge *p; p = x; for(n=0; n<512; ++n) ++p; Now, *p is OK (i.e. not x[0]). This doesn't work either: n = 512; x[(long)n] is still the same as x[0]. Clearly, when handling arrays, the compiler is simply adding to the offset of the huge pointer, and is not properly adjusting the segment (or not using long arithmetic to multiply n and sizeof(struct x)). This problem occurs in both the S and the L memory models (and probably all of the others). So, is there any way to use an array of structures that totals more than 64kb, without doing all of the groty arithmetic myself? Tom Roberts ihnet!tjr