On Thu, Sep 06, 2012 at 11:10:37PM +0200, Jakub Jelinek wrote:
> > +       int expected(0);
> >         if (__atomic_compare_exchange_n(gi, &expected, pending_bit, false,
> >                                         __ATOMIC_ACQ_REL,
> >                                         __ATOMIC_RELAXED))
> 
> Shouldn't this __ATOMIC_RELAXED be also __ATOMIC_ACQUIRE?  If expected ends
> up being guard_bit, then the code will return 0; right away.

Here is a patch for that.  Ok for trunk/4.7?

2012-09-11  Jakub Jelinek  <ja...@redhat.com>

        PR libstdc++/54172
        * libsupc++/guard.cc (__cxa_guard_acquire): Fix up the last
        argument of the first __atomic_compare_exchange_n.

--- libstdc++-v3/libsupc++/guard.cc.jj  2012-09-11 16:55:16.000000000 +0200
+++ libstdc++-v3/libsupc++/guard.cc     2012-09-11 16:56:38.035848876 +0200
@@ -253,7 +253,7 @@ namespace __cxxabiv1
            int expected(0);
            if (__atomic_compare_exchange_n(gi, &expected, pending_bit, false,
                                            __ATOMIC_ACQ_REL,
-                                           __ATOMIC_RELAXED))
+                                           __ATOMIC_ACQUIRE))
              {
                // This thread should do the initialization.
                return 1;

        Jakub

Reply via email to