------- Comment #68 from jakub at gcc dot gnu dot org 2010-06-03 16:58 ------- That makes sense, so all we need to do in config/tls.m4 is probably: 1) move a_in_main_thread variable to file scope, and neither a_in_main_thread nor a_in_other_thread should be static 2) move a_in_main_thread = &a; before pthread_create That should be IMHO all that is needed, the compiler can't then move a_in_main_thread assignment after pthread_create. Or to be really sure make a_in_main_thread and a_in_other_thread volatile too.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43170