public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13668] New: thread local storage: static class member does not work
@ 2004-01-13 14:51 simon dot marshall at misys dot com
2004-01-13 14:54 ` [Bug c++/13668] " simon dot marshall at misys dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: simon dot marshall at misys dot com @ 2004-01-13 14:51 UTC (permalink / raw)
To: gcc-bugs
A static class member should be able to be thread local:
class foo {
static __thread int i;
};
__thread int foo::i = 0;
foo bar;
If bar.i is used in the same file as where bar is instantiated, then bar.i is
indeed thread-local. However, if bar.i is used in another file, then it is
not. This appears to be a bug.
Assuming I manage to attach the testcase to this report: The testcase contains
3 source files: __thread.hpp, __thread.cpp defining foo(), __threadmain.cpp
defining main(). Build a.out using the supplied Makefile.
__thread.hpp declares 2 classes, class Encap and template wrapper Templ. Both
contain static thread-local members.
__threadmain.cpp instantiates 3 objects: one a thread-local POD, one of Encap,
one using Templ. Its main() creates threads running function foo().
__thread.cpp foo() sets the POD and thread-local values of the Encap instance
and Templ instance to the thread id. It outputs the thread-local values and
their addresses at the start of foo() and end of foo().
In the test case, only the POD appears to be thread-local. The Encap instance
and Templ instance are not. The file a.1 shows that, as foo() exits in the
different threads, the thread-local values are incorrect. Not surprising, as
the address of each of the thread-local members of Encap and Templ are the
same. This is a bug.
If the instantiations of Encap and Templ are moved from __threadmain.cpp to
__thread.cpp (where foo() is defined and the instances are used), then all are
thread-local. The addresses of each of the thread-local members of Encap and
Templ are different, as I would expect. This is correct.
This is on rh9.
llama 200> gcc -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: ../configure --enable-shared --enable-threads=posix --with-
system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.3.2
llama 201> ld -v
GNU ld version 2.13.90.0.18 20030206
llama 202> as -v
GNU assembler version 2.13.90.0.18 (i386-redhat-linux) using BFD version
2.13.90.0.18 20030206
llama 203> uname -a
Linux llama 2.4.20-28.9smp #1 SMP Thu Dec 18 13:37:36 EST 2003 i686 i686 i386
GNU/Linux
Note that the Solaris CC 5.5 compiler does the right thing.
--
Summary: thread local storage: static class member does not work
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: simon dot marshall at misys dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13668] thread local storage: static class member does not work
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
@ 2004-01-13 14:54 ` simon dot marshall at misys dot com
2004-01-17 1:01 ` feanor-list at tol-eressea dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: simon dot marshall at misys dot com @ 2004-01-13 14:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From simon dot marshall at misys dot com 2004-01-13 14:54 -------
Created an attachment (id=5473)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5473&action=view)
test case
Attached is a test case to demonstrate the bug. The test case is described in
the bug comment.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13668] thread local storage: static class member does not work
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
2004-01-13 14:54 ` [Bug c++/13668] " simon dot marshall at misys dot com
@ 2004-01-17 1:01 ` feanor-list at tol-eressea dot org
2004-01-17 1:03 ` feanor-list at tol-eressea dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: feanor-list at tol-eressea dot org @ 2004-01-17 1:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From feanor-list at tol-eressea dot org 2004-01-17 01:01 -------
Created an attachment (id=5506)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5506&action=view)
Two thread, one static variable, three addresses:))
Try to compile this little program and you'll some funny behaviour.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13668] thread local storage: static class member does not work
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
2004-01-13 14:54 ` [Bug c++/13668] " simon dot marshall at misys dot com
2004-01-17 1:01 ` feanor-list at tol-eressea dot org
@ 2004-01-17 1:03 ` feanor-list at tol-eressea dot org
2004-01-18 18:16 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: feanor-list at tol-eressea dot org @ 2004-01-17 1:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From feanor-list at tol-eressea dot org 2004-01-17 01:03 -------
(In reply to comment #2)
> Created an attachment (id=5506)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5506&action=view)
> Two thread, one static variable, three addresses:))
>
> Try to compile this little program and you'll some funny behaviour.
The is the output on g++ 3.3.2 on debian:
__display value: 0x804a058, address: 0x8049c68 in thread 1085393872
__display value: (nil), address: 0x40b1cbc8 in thread 1085393872
disp (nil)
__display value: 0x804c3f8, address: 0x8049c68 in thread 1085393872
__display value: (nil), address: 0x40b1cbc8 in thread 1085393872
__display value: 0x804b090, address: 0x8049c68 in thread 1077004064
__display value: (nil), address: 0x4031c718 in thread 1077004064
disp (nil)
Erreur de segmentation
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13668] thread local storage: static class member does not work
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
` (2 preceding siblings ...)
2004-01-17 1:03 ` feanor-list at tol-eressea dot org
@ 2004-01-18 18:16 ` pinskia at gcc dot gnu dot org
2004-01-21 9:47 ` simon dot marshall at misys dot com
2004-01-21 13:54 ` bangerth at dealii dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-18 18:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-01-18 18:16 -------
This is not a gcc bug, this is a bug in glibc.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13668] thread local storage: static class member does not work
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
` (3 preceding siblings ...)
2004-01-18 18:16 ` pinskia at gcc dot gnu dot org
@ 2004-01-21 9:47 ` simon dot marshall at misys dot com
2004-01-21 13:54 ` bangerth at dealii dot org
5 siblings, 0 replies; 7+ messages in thread
From: simon dot marshall at misys dot com @ 2004-01-21 9:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From simon dot marshall at misys dot com 2004-01-21 09:47 -------
(In reply to comment #4)
> This is not a gcc bug, this is a bug in glibc.
Thanks. Do I have to do something to report it to the glibc maintainers or is
the issue already known by them?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13668] thread local storage: static class member does not work
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
` (4 preceding siblings ...)
2004-01-21 9:47 ` simon dot marshall at misys dot com
@ 2004-01-21 13:54 ` bangerth at dealii dot org
5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-01-21 13:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-01-21 13:54 -------
You may want to post to the glibc bug reporting list.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13668
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-01-21 13:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-13 14:51 [Bug c++/13668] New: thread local storage: static class member does not work simon dot marshall at misys dot com
2004-01-13 14:54 ` [Bug c++/13668] " simon dot marshall at misys dot com
2004-01-17 1:01 ` feanor-list at tol-eressea dot org
2004-01-17 1:03 ` feanor-list at tol-eressea dot org
2004-01-18 18:16 ` pinskia at gcc dot gnu dot org
2004-01-21 9:47 ` simon dot marshall at misys dot com
2004-01-21 13:54 ` bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).