Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!ucbvax!agate!bionet!arisia!roo!xerox!barbarin From: barbarin@Xerox.com (Mike Barbarino) Newsgroups: comp.lang.c++ Subject: TC++ problem? cont. Message-ID: <680@roo.UUCP> Date: 18 Dec 90 21:55:45 GMT Sender: news@parc.xerox.com Reply-To: barbarin@Xerox.com (Mike Barbarino) Organization: Xerox PARC Lines: 36 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 #include 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; } } }