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

--- Comment #15 from Giuseppe D'Angelo <dangelog at gmail dot com> ---
That's not what I meant; a type can be trivial(ly copyable) and move-only.

Here's a modification of Arthur's example:

// move-only
struct B {
    B(int i, short j) : i(i), j(j) {}
    B(B &&) = default;
    B &operator=(B &&) = default;
    int i;
    short j; 
};
struct D : B {
    D(int i, short j, short x) : B(i, j), x(x) {}
    D(D &&) = default;
    D &operator=(D &&) = default;
    short x;
};
int main() {
    D ddst(1, 2, 3);
    D dsrc(4, 5, 6);
    B *dst = &ddst;
    B *src = &dsrc;
    static_assert(std::is_trivially_copyable_v<B>);

    std::move(src, src+1, dst);
    assert(ddst.x == 3); 
}


The call to std::move ends up in the same memmove codepath as std::copy_n (B is
trivially copyable), but with the proposed patch it will fail to compile
because it's not actually copy assignable.

Reply via email to