There is a problem in the __rw_atomic_preincrement function versions for
Win32 (see the include\rw\_mutex.h file, line 1352):
inline int
__rw_atomic_preincrement (int &__x, bool)
{
_RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
return InterlockedIncrement (_RWSTD_REINTERPRET_CAST (long*, __x));
}
This
_RWSTD_REINTERPRET_CAST (long*, __x)
tries to cast __x (not &__x !) to the long*.
After the casting the created temporary variable (to be passed to the
InterlockedIncrement function) contains the value of __x interpreted as
an valid address.
This results in that all stdcxx library examples crash. (They use
std::cout which uses these functions ?)
The same problem is in __rw_atomic_predecrement and
__rw_atomic_exchange.
Looks like instead of
_RWSTD_REINTERPRET_CAST (long*, __x)
should be
_RWSTD_REINTERPRET_CAST (long*, &__x)
?
With best wishes,
Anton Pevtsov.
|