From b00e0714e621fcf1cc56a46624f90cf15507a8db Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 20 Sep 2018 12:21:24 +0000 Subject: [PATCH] [ADT] Bring back memmove to make GCC 5.4 happy All other GCCs look good so far. GCC 5.4 complains about strict aliasing, so fix that. llvm-svn: 342643 --- llvm/include/llvm/ADT/Optional.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h index 9242a0a..c09c9c7 100644 --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -22,6 +22,7 @@ #include "llvm/Support/type_traits.h" #include #include +#include #include #include @@ -115,9 +116,11 @@ template struct OptionalStorage { OptionalStorage() = default; - OptionalStorage(const T &y) : hasVal(true) { new (storage.buffer) T(y); } + OptionalStorage(const T &y) : hasVal(true) { + std::memmove(storage.buffer, &y, sizeof(y)); + } OptionalStorage &operator=(const T &y) { - *reinterpret_cast(storage.buffer) = y; + std::memmove(storage.buffer, &y, sizeof(y)); hasVal = true; return *this; } -- 2.7.4