From: Benjamin Kramer Date: Thu, 20 Sep 2018 12:21:24 +0000 (+0000) Subject: [ADT] Bring back memmove to make GCC 5.4 happy X-Git-Tag: llvmorg-8.0.0-rc1~8337 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b00e0714e621fcf1cc56a46624f90cf15507a8db;p=platform%2Fupstream%2Fllvm.git [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 --- 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; }