struct NODE{ struct NODE Succ; struct NODE Prev; }; struct LIST{ struct NODE *Head; struct NODE *Tail; int count; }; struct LIST *List; struct NODE *N; ...... for(N = List->Head;N;N = N->Succ) { ...... }
List is placed in XDATA because I use the large memory model (see message)... "N is never used in the code hence it doesn't matter where it is placed: " N is used in code: "N = List->Head" and "N = N->Succ" in the for-loop. In small model I get the following map-file:
VALUE REP CLASS TYPE SYMBOL NAME ==================================================== --- MODULE --- --- MAIN 01000003H PUBLIC CODE --- main 01000003H BLOCK CODE --- LVL=0 01000003H BLOCK CODE NEAR LAB LVL=1 00000008H SYMBOL DATA --- List 00000001H SYMBOL DATA --- N --- BLOCKEND --- --- LVL=1 --- BLOCKEND --- --- LVL=0
"List is placed in XDATA because I use the large memory model" Ok, but shouldn't N therefore be placed in xdata as well? Quoting from your map file above: 02000000H SYMBOL XDATA --- List 00000001H SYMBOL DATA --- N "N is used in code: "N = List->Head" and "N = N->Succ" in the for-loop" Yes, I must have been sleeping. Again. I think Hans is right, the optimisation is legitimately causing this. The order of events is (pseudocode): List=An address; N=List->Head; LABEL: N=N->Succ; if(N) goto LABEL So, List and N can occupy the same location without anything going wrong. Stefan