------- 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

Reply via email to