This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53036] New: [c++11] trivial class fails std::is_trivial test


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");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]