[PATCH] D54540: [ADT] Drop llvm::Optional clang-specific optmization for trivially copyable types

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 16 10:53:11 PST 2018


rjmccall added inline comments.


================
Comment at: llvm/trunk/include/llvm/ADT/Optional.h:121
-  OptionalStorage &operator=(const T &y) {
-    *reinterpret_cast<T *>(storage.buffer) = y;
-    hasVal = true;
----------------
I wonder if GCC's problem is that we haven't formally created an object of type T at this address, and the assignment isn't good enough  We could just placement-`new` here; you're allowed to just replace objects like that when the destructor is trivial.


Repository:
  rL LLVM

https://reviews.llvm.org/D54540





More information about the llvm-commits mailing list