This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: PATCH for thread-safe C++ static local initialization
- From: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Benjamin Kosnik <bkoz at redhat dot com>
- Date: Fri, 20 Aug 2004 18:18:42 -0500
- Subject: Re: RFC: PATCH for thread-safe C++ static local initialization
> static <type> guard;
> if (!guard.first_byte) {
> if (__cxa_guard_acquire (&guard)) {
> bool flag = false;
> try {
> // Do initialization.
> flag = true; __cxa_guard_release (&guard);
> // Register variable for destruction at end of program.
> } catch {
> if (!flag) __cxa_guard_abort (&guard);
> }
> }
> }
I assume that this is just my misunderstanding of the inner workings of how
the guard works, but isn't there
a) a second if(!guard.first_byte) missing inside the guarded block? (Some
other thread may have set it between out checking for the flag and getting to
the __cxa_guard_acquire.)
b) code missing to set guard.first_byte to something nonzero?
In any case, the main point of this mail is to point you (and this archived
thread) to
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13684
which you are doubtlessly aware of and which discusses this stuff.
Thanks
Wolfgang
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/