I ran into this problem with stock gcc-4.0.2 on Fedora Core 2. The problem shows when the following code is compiled with -O2: the address of "array" seems to be cached and reused across calls to function "h". This becomes a problem when function h saves its execution context in one thread and resumes in another thread (thus the address of array changes before and after the call). Is this a feature or a bug? How could I instruct gcc not to reuse thread local addresses acrosses function calls? Thanks.
__thread int array[1]; int *f() { for (;;) h(array); return array; } -- Summary: liveness of thread local references across function calls Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yichen dot xie at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461