[PATCH] D50710: [ADT] Fix Optional ABI mismatch between clang & gcc
Tim Shen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 20 10:03:29 PDT 2018
timshen added inline comments.
================
Comment at: include/llvm/ADT/Optional.h:120
OptionalStorage &operator=(const T &y) {
- *reinterpret_cast<T *>(storage.buffer) = y;
- hasVal = true;
+ if (hasVal) {
+ // Use std::addressof to silence strict-aliasing warnings from gcc.
----------------
timshen wrote:
> Will this suffice?
> `if (hasVal) { memcpy(&storage.buffer, &y.storage.buffer, sizeof(T)); }`
Sorry, I meant
hasVal = y.hasVal;
if (hasVal) { memcpy(...); }
Repository:
rL LLVM
https://reviews.llvm.org/D50710
More information about the llvm-commits
mailing list