Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!ames!ucbcad!ucbvax!hplabs!hp-pcd!orstcs!go From: go@orstcs.UUCP Newsgroups: comp.sys.ibm.pc Subject: Bug in Microsoft C 4.00? Message-ID: <216700008@orstcs.UUCP> Date: Fri, 13-Feb-87 02:35:00 EST Article-I.D.: orstcs.216700008 Posted: Fri Feb 13 02:35:00 1987 Date-Received: Sun, 15-Feb-87 08:20:11 EST Organization: Oregon State University - Corvallis, OR Lines: 41 Nf-ID: #N:orstcs:216700008:000:1053 Nf-From: orstcs!go Feb 12 23:35:00 1987 [in case of line eater] I don't know if anyone has reported this as a bug in this group, but here goes... In Microsoft C 4.00, (actually more a linker problem, but it's the linker supplied with the compiler) the linker can, in some cases, allocate memory to variables, such that the variables overlap. Consider the two modules: /* module a */ int array1[100]; main() { extern int array2[]; printf("address of array1 is %x, end of array1 is %x\n", array1, array1+sizeof(array1)); printf("address of array2 is %x\n", array2); } /* end of module a*/ /* module b */ int array2[100]; /* end of module b */ Compile both using the small (default) memory model and link with slibc and run. You will find that array2 is allocated somewhere within the limits of array1. The problem disappears if you explicitely initialize either array. I have not yet tried this on any other memory models. Is this a bug or am I just too tired to see what's wrong? Gary Oliver ...!hp-pcd!orstcs!go [Perhaps we need a comp.sys.ibm.pc.microsoft.bugs :-) ]