mcdonald@uxe.cso.uiuc.edu (12/19/88)
I tried compiling the following LEGAL C program (note the line struct six s[10000]; ) under various memory models of Microsoft C , and all failed, including Huge. (The declaration for "diff" was changed to K&R 1st edition style for later use. The original way does the same under Microsoft C). The problem lies ONLY in the huge model: one cannot expect this to work with both the -100 and +10000 answers, because one requires signed division, the other unsigned. struct six { int i[3]; }; int diff(p,q) struct six *p; struct six *q; { return p - q; } main(void) { struct six s[10000]; printf("%d\n", diff(s+10000, s)); /* 10000 */ printf("%d\n", diff(s, s+100)); /* -100 */ } Okay, then I tried compiling and running it using MicroWay NDP C on my Model 80. It gave the correct answer, just as I would expect it to. FINALLY, I changed "diff(s+10000,s)" to "diff(s+500000000,s)" (note, no change in the declaration of s), recompiled under NDP C and got 142086058 -100 which is wrong, just as I would have expected. Microsoft C is still broken. NDP C isn't - it is unequivocally, definitely, small model (32 bit ints, 32 bit pointers, no "far" keyword.) Doug McDonald