cquenel@polyslo.CalPoly.EDU (Suspended in Gaffa) (11/21/88)
In article <6472@june.cs.washington.edu> pardo@cs.washington.edu (David Keppel) writes: [stuff about taking the address of a local variable] I believe that the way this is COMMONLY dealt with is the following: When the compiler sees the address taken of a local variable, it is forced to treat this as basically "volatile" in a way. All modifications to that variable must be written out to memory AT THE EARLIER location. This variable cannot be moved. Now, some optimizations are possible. -- If the address goes into a local variable only, the compiler can keep track of it's use, and verify correctness within this function. -- however, if the value gets stored into a global variable or passed to a function, then all bets are off. Any following function call or global pointer reference (after a function call), could use that pointer value. So, the summary is : DON'T TAKE THE ADDRESSES OF VARIABLES IF YOU WANT YOUR COMPILER TO DO OPTIMIZATIONS!!! --chris The more things change, the more they stay insane. ------------------------------------------------------------------------------- | Chris Quenelle | Smart Mailers -> cquenel@polyslo.CalPoly.EDU | | Computer Systems Lab | Dumb Mailers -> !ucbvax!voder!polyslo!cquenel | | Cal Poly State Univ. |-------------------------------------------------| | San Luis Obispo, CA 93407 | My computer can beat up your computer. - Karl | -------------------------------------------------------------------------------