This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/20979] __gnu_cxx::bitmap_allocator export pruning
- From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Apr 2005 16:32:19 -0000
- Subject: [Bug libstdc++/20979] __gnu_cxx::bitmap_allocator export pruning
- References: <20050412214615.20979.bkoz@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bkoz at gcc dot gnu dot org 2005-04-13 16:32 -------
I posit that this usage of static local variables, as written, is thread safe
with gcc-4.0.x compilers. (Since resolution of c++/13684).
! _Mutex*
! _M_get_mutex()
! {
! static _Mutex _S_mutex;
! return &_S_mutex;
! }
This object is only constructed (and initialized) once. After initial
construction, a pointer to the initial object is returned. Don't let the
simplicity of this solution fool you!
This change actually improves portability for initialization, especially on
non-SVR4 platforms, where order of initalization of static objects may differ
from expectations.
-benjamin
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20979