This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/53901] New: [C++11] std::atomic<T> fails for type without trivial default constructor and trivial destructor
- 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, 09 Jul 2012 15:32:25 +0000
- Subject: [Bug libstdc++/53901] New: [C++11] std::atomic<T> fails for type without trivial default constructor and trivial destructor
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53901
Bug #: 53901
Summary: [C++11] std::atomic<T> fails for type without trivial
default constructor and trivial destructor
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
This fails to compile:
#include <atomic>
struct T {
T noexcept(false) { }
~T noexcept(false) { }
};
std::atomic<T> a;
g++ -std=c++11 ex.cc
In file included from ex.cc:1:0:
/home/jwakely/gcc/4.x/include/c++/4.8.0/atomic: In instantiation of 'struct
std::atomic<T>':
ex.cc:16:21: required from here
/home/wakelj/tools/Linux-f12-x86_64/4.8/include/c++/4.8.0/atomic:163:7: error:
function 'std::atomic<_Tp>::atomic() [with _Tp = T]' defaulted on its first
declaration with an exception-specification that differs from the implicit
declaration 'std::atomic<T>::atomic()'
atomic() noexcept = default;
^
/home/jwakely/gcc/4.x/include/c++/4.8.0/atomic:164:7: error: function
'std::atomic<_Tp>::~atomic() [with _Tp = T]' defaulted on its first declaration
with an exception-specification that differs from the implicit declaration
'std::atomic<T>::~atomic()'
~atomic() noexcept = default;
^
I believe the only requirement on the type T is that it's trivially copyable.
The defaulted constructor and destructor in atomic<T> need to be declared in
the class then defined as deleted later.