This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/67572] New: std::atomic, std::mutex and others are trivially copyable
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 Sep 2015 12:03:11 +0000
- Subject: [Bug libstdc++/67572] New: std::atomic, std::mutex and others are trivially copyable
- Auto-submitted: auto-generated
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).