Boost logo

Boost :

From: Hynek Petrak (hynek_at_[hidden])
Date: 2003-12-30 08:38:18


I'm sending a patch for two issues I found in atomic_count_gcc.hpp

1. The atomic_count.hpp says:
      operator --() .... returns: (long) zero if the new value of a is zero,
       unspecified non-zero value otherwise (usually the new value)
  But because __exchange_and_add(...) returns the original (and not the
new) value,
  atomic_count_gcc::operator--() returns 0 always when the original
value was != 0 i.e. the new value is != -1.

2. My gcc (GCC) 3.3.1 (SuSE Linux) complains that it can't convert
const _Atomic_word to volatile _Atomic_word.

Best regards

    Hynek Petrak

*** boost/detail/atomic_count_gcc.hpp.orig>.Tue Dec 30 13:08:04 2003
--- boost/detail/atomic_count_gcc.hpp>..Tue Dec 30 13:10:03 2003
***************
*** 38,49 ****

      long operator--()
      {
! return !__exchange_and_add(&value_, -1);
      }

      operator long() const
      {
! return __exchange_and_add(&value_, 0);
      }

  private:
--- 38,49 ----

      long operator--()
      {
! return __exchange_and_add(&value_, -1)-1;
      }

      operator long() const
      {
! return __exchange_and_add(&(_Atomic_word)value_, 0);
      }

  private:
~


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk