[Bug libstdc++/67572] New: std::atomic, std::mutex and others are trivially copyable
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Sep 14 12:03:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67572
Bug ID: 67572
Summary: std::atomic, std::mutex and others are trivially
copyable
Product: gcc
Version: 4.9.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <atomic>
#include <mutex>
#include <shared_mutex>
#include <type_traits>
static_assert( !std::is_trivially_copyable<std::atomic<int>>::value,
"atomic<int>" );
static_assert( !std::is_trivially_copyable<std::mutex>::value, "mutex" );
static_assert( !std::is_trivially_copyable<std::timed_mutex>::value,
"timed_mutex" );
static_assert( !std::is_trivially_copyable<std::shared_timed_mutex>::value,
"shared_timed_mutex" );
Being non-copyable and non-movable doesn't stop a type being non-trivially
copyable, so to ensure users don't think it's OK to memcpy these types we need
to fix them (e.g. by adding a user-defined destructor).
More information about the Gcc-bugs
mailing list