This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/54129] emulated __thread variables and pthread_*specific data
- From: "blucia at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jul 2012 20:25:52 +0000
- Subject: [Bug middle-end/54129] emulated __thread variables and pthread_*specific data
- Auto-submitted: auto-generated
- References: <bug-54129-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54129
--- Comment #2 from blucia at gmail dot com 2012-07-30 20:25:52 UTC ---
The man page for pthread_key_create says:
"An optional destructor function may be associated with each key value. ...
The order of destructor calls is unspecified if more than one destructor exists
for a thread when it exits."
That's fine, but I did not register any destructor function for the __thread
variables that are getting zeroed! In my program, only one destructor function
exists.
It seems a little weird that those __thread variables are being zeroed at all.
Again, I'm not sure what the spec says, but it seems like a better default
behavior would be to let them retain their values until termination, unless
explicitly altered elsewhere. Doubly so, because it already does that on
Linux, and copying that behavior makes code more portable.