diff --git a/core/templates/local_vector.h b/core/templates/local_vector.h index b59f8687976..d20fe49eba6 100644 --- a/core/templates/local_vector.h +++ b/core/templates/local_vector.h @@ -295,10 +295,16 @@ public: operator Vector() const { Vector ret; - ret.resize(size()); + ret.resize(count); T *w = ret.ptrw(); if (w) { - memcpy(w, data, sizeof(T) * count); + if constexpr (std::is_trivially_copyable_v) { + memcpy(w, data, sizeof(T) * count); + } else { + for (U i = 0; i < count; i++) { + w[i] = data[i]; + } + } } return ret; }