Subj : Re: What does Memory Barriers mean ?? To : comp.programming.threads From : David Hopwood Date : Sun Jan 09 2005 07:33 pm David Schwartz wrote: > "SenderX" wrote: > >>Here is a question on compiler reordering wrt C... >> >>extern void assembly_routine_1( void** ); >>extern void assembly_routine_2( void** ); >> >>/* code */ >> >>void *p1, *p2; >> >>1: assembly_routine_1( &p1 ); >>2: assembly_routine_2( &p2 ); >> >> >>Since call 2 dosen't rely on anything from call 1, could the compiler >>could execute call 2 before call 1? > > The answer is: Assuming you are following the relevant standards, the > compiler can reorder the functions if and only if you cannot tell the > difference. No. Calling an assembly routine, unless it is a standard library function, already causes undefined behaviour according to the standards. In practice you're at the mercy of whatever your compiler happens to do at the selected optimization level. -- David Hopwood .