Index: clang/lib/AST/Interp/ByteCodeEmitter.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeEmitter.cpp +++ clang/lib/AST/Interp/ByteCodeEmitter.cpp @@ -163,8 +163,15 @@ } if constexpr (!std::is_pointer_v) { - const char *Data = reinterpret_cast(&Val); - Code.insert(Code.end(), Data, Data + Size); + if constexpr (std::is_trivially_copyable_v) { + const char *Data = reinterpret_cast(&Val); + Code.insert(Code.end(), Data, Data + Size); + } else { + // Construct the value directly into our storage vector. + size_t ValPos = Code.size(); + Code.resize(Code.size() + Size); + new (Code.data() + ValPos) T(Val); + } } else { uint32_t ID = P.getOrCreateNativePointer(Val); const char *Data = reinterpret_cast(&ID);