[llvm] r342643 - [ADT] Bring back memmove to make GCC 5.4 happy
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 05:21:24 PDT 2018
Author: d0k
Date: Thu Sep 20 05:21:24 2018
New Revision: 342643
URL: http://llvm.org/viewvc/llvm-project?rev=342643&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/ADT/Optional.h
Modified: llvm/trunk/include/llvm/ADT/Optional.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Optional.h?rev=342643&r1=342642&r2=342643&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Optional.h (original)
+++ llvm/trunk/include/llvm/ADT/Optional.h Thu Sep 20 05:21:24 2018
@@ -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 OptionalSto
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;
}
More information about the llvm-commits
mailing list