[Bug libstdc++/40297] New: [C++0x] debug mode vs atomics
jwakely dot gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri May 29 17:38:00 GMT 2009
The atomic types in <cstdatomic> have debug-mode assertions that will always
fail.
#define _GLIBCXX_DEBUG
#include <cstdatomic>
int main()
{
std::atomic_address ptr;
return ptr.load() ? 0 : 1;
}
Fails with:
/dev/shm/wakelyjo/insroot/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/atomic_2.h:114:
void* std::__atomic2::atomic_address::load(std::memory_order) const volatile:
Assertion '__m == memory_order_release' failed.
Due to:
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
__glibcxx_assert(__m == memory_order_release);
__glibcxx_assert(__m == memory_order_acq_rel);
__sync_synchronize();
void* __ret = _M_i;
__sync_synchronize();
return __ret;
}
Since memory_order is an enumeration and each enumerator has a distinct value,
it's not possible for both assertions to pass.
I'm not sure what they were intended to check, unless it's to prevent atomics
being used in debug mode!
--
Summary: [C++0x] debug mode vs atomics
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jwakely dot gcc at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40297
More information about the Gcc-bugs
mailing list