[Bug libstdc++/114817] Wrong codegen for std::copy of "trivially copyable but not trivially assignable" type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114817 --- Comment #3 from Arthur O'Dwyer --- https://github.com/boostorg/container/issues/153 , from 2020, is another similar issue. There, boost::container::vector had assumed that if __has_trivial_copy(T) and is_copy_constructible_v, then T could be relocated via memcpy; but in fact __has_trivial_copy(T) is also true for move-only types. So it was possible to create a type such that (__has_trivial_copy(T) && __is_constructible(T, T&)) and yet not __is_trivially_constructible(T, T&). // https://godbolt.org/z/x5Wda1M6E struct T { template T(U&&); T(T&&); ~T(); }; static_assert(__has_trivial_copy(T) && __is_constructible(T, T&)); // ...and yet... static_assert(not __is_trivially_constructible(T, T&));
[Bug libstdc++/114817] Wrong codegen for std::copy of "trivially copyable but not trivially assignable" type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114817 Jiang An changed: What|Removed |Added CC||de34 at live dot cn --- Comment #2 from Jiang An --- Bug 106547 seems somehow related.
[Bug libstdc++/114817] Wrong codegen for std::copy of "trivially copyable but not trivially assignable" type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114817 --- Comment #1 from Arthur O'Dwyer --- Yes, vector reallocation has analogous trouble with types that are "trivial, but not trivially copy constructible." https://godbolt.org/z/Psboqf3MP (libc++ happens to sidestep this pitfall *on Clang 15+,* because libc++ gates their vector reallocation optimization differently depending on whether `__has_builtin(__is_trivially_relocatable)`; but libc++ would have the same bug as libstdc++ when compiled on GCC.)