https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120633

            Bug ID: 120633
           Summary: std::is_trivially_copyable_v in C++20
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

We claim to support P0848R3.  When looking at the
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2786r13.html#simple-worked-examples
testcases, I see 3 failures in the is_trivially_copyable_v tests.
https://eel.is/c++draft/class.prop#1 changed in that paper.
For the C case, the first 2 user declared special member functions are IMHO not
eligible because they are explicitly deleted, and the implicitly declared copy
ctor and copy assignment operator are deleted too because move ctor and move
assignment operators are both declared.  In the K case, the dtor is explicitly
deleted, I think it is incorrect even for C++17:
A trivially copyable class is a class: ... that has a trivial, non-deleted
destructor.
And for the last case, move ctor is explicitly deleted, copy ctor is implicitly
declared as deleted, copy assignment operator likewise, and move assignment
operator is not implicitly nor explicitly declared.  So it has no eligible
{copy,move} {ctor,assignment operator} and so shouldn't be trivially copyable
since the paper either.
Though not sure if it was valid in C++17 either, while
where each copy constructor, move constructor, copy assignment operator, and
move assignment operator is either deleted or trivial,
is true (all 3 are deleted, one is missing)
"that has at least one non-deleted copy constructor, move constructor, copy
assignment operator, or move assignment operator"
is not true.

#include <type_traits>

struct C {
  C (C &&) = delete;
  C &operator= (C &&) = delete;
  C () = default;
};
struct K { ~K () = delete; };
struct N { N (N &&) = delete; };

static_assert (!std::is_trivially_copyable_v <C>, "");
static_assert (!std::is_trivially_copyable_v <K>, "");
static_assert (!std::is_trivially_copyable_v <N>, "");

Reply via email to