diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2018-09-20 12:21:24 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2018-09-20 12:21:24 +0000 |
| commit | b00e0714e621fcf1cc56a46624f90cf15507a8db (patch) | |
| tree | f6488d7deafbce52ca847c33a8f17c399289473f /llvm/include | |
| parent | 46c1dcb1af7cd63c3475a6cb15fbaf9b5873784e (diff) | |
| download | bcm5719-llvm-b00e0714e621fcf1cc56a46624f90cf15507a8db.tar.gz bcm5719-llvm-b00e0714e621fcf1cc56a46624f90cf15507a8db.zip | |
[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
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/ADT/Optional.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h index 9242a0afcbc..c09c9c77b25 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 <algorithm> #include <cassert> +#include <cstring> #include <new> #include <utility> @@ -115,9 +116,11 @@ 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::memmove(storage.buffer, &y, sizeof(y)); + } OptionalStorage &operator=(const T &y) { - *reinterpret_cast<T *>(storage.buffer) = y; + std::memmove(storage.buffer, &y, sizeof(y)); hasVal = true; return *this; } |

