All other GCCs look good so far. GCC 5.4 complains about strict
aliasing, so fix that.
llvm-svn: 342643
#include "llvm/Support/type_traits.h"
#include <algorithm>
#include <cassert>
+#include <cstring>
#include <new>
#include <utility>
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;
}