------- Comment #18 from davids at webmaster dot com 2009-02-25 16:06 ------- This is a real bug. There is simply no way to write correct threaded code if the compiler is free to read a variable and write it back when the code didn't specifically tell it to.
Optimizations on threaded code cannot add a write to a variable unless they can prove no other thread could know the location of the variable. (It's local, it's address has never been passed to a function, and so on.) In any event, the last time I looked into this, it seemed that such 'optimizations' were typically pessimizations on multi-threaded code anyway, as they added expensive cache misses. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31862