diff options
-rw-r--r-- | llvm/include/llvm/ADT/Optional.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h index c628df9d711..f7d35c745fb 100644 --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -116,7 +116,9 @@ template <typename T> struct OptionalStorage<T, true> { OptionalStorage() = default; - OptionalStorage(const T &y) : hasVal(true) { new (storage.buffer) T(y); } + OptionalStorage(const T &y) : hasVal(true) { + std::memcpy(storage.buffer, reinterpret_cast<char const *>(&y), sizeof(T)); + } OptionalStorage(const OptionalStorage &O) = default; OptionalStorage(T &&y) : hasVal(true) { std::memcpy(storage.buffer, reinterpret_cast<char*>(&y), sizeof(T)); |