This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53036] New: [c++11] trivial class fails std::is_trivial test
- From: "eric.niebler at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Apr 2012 22:08:34 +0000
- Subject: [Bug c++/53036] New: [c++11] trivial class fails std::is_trivial test
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53036
Bug #: 53036
Summary: [c++11] trivial class fails std::is_trivial test
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: eric.niebler@gmail.com
In my understanding of the new C++ standard, the following code should compile.
It does not.
struct D
{
D() = default;
D(D const &) = default;
template<typename ...U>
constexpr D(U ...u)
{}
};
static_assert(std::is_trivial<D>::value, "here");
The problem is the variadic constexpr constructor. I'm guessing here that the
problem is that it could also be used as a default constructor, making the type
non-trivial. However, I have explicitly defaulted the default constructor, so
the variadic constructr should never be considered for 0 arguments.
I base the above supposition on the fact that if I add a dummy argument to the
variadic as below, it works:
struct D
{
D() = default;
D(D const &) = default;
template<typename ...U>
constexpr D(int, U ...u) // dummy arg, not default c'tor, ok.
{}
};
static_assert(std::is_trivial<D>::value, "here");