barbarin@Xerox.com (Mike Barbarino) (12/19/90)
Sorry I messed up my previous posting. I should have posted the actual source rather
than hand-copy from the PC display. I apologize for wasting the time of all who
replied...
Here is the test program. It was compiled under huge and large memory models. I
initially had DBSIZE set to 30000 (just to see if I could access past 64K). Since the
problem occurs even when DBSIZE is small, I reset DBSIZE to 30 so that I could do
my debugging in the IDE.
The problem is this: "weight" doesn't seem to get set correctly, the "for" loop bails
out immediately (more or less). If I swap "hits" and "weight" in the struct, the
loop finishes correctly. What's the reason for the inconsistency?
#include <alloc.h>
#include <iostream.h>
main(){
struct weights {
long hits;
long weight;
};
weights huge *accumulator;
const long DBSIZE = 30L;
const long MEMSIZE = DBSIZE * sizeof(weights);
accumulator = (weights huge*)farmalloc(MEMSIZE);
for (int j = 0; j < DBSIZE; j++, accumulator++) {
accumulator->weight = 255;
if ((accumulator->weight) != 255) {
cout << "WHAT HAPPENED AT " << j << endl;
break;
}
}
}