Commit ed83e5fd authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix folly/Poly-inl.h under gcc8 with -Wplacement-new

Summary:
[Folly] Fix `folly/Poly-inl.h` under gcc8 with `-Wplacement-new`.

```
In file included from folly/Poly.h:1169,
                 from folly/test/PolyTest.cpp:19:
folly/Poly-inl.h: In instantiation of 'folly::detail::PolyVal<I>::PolyVal(T&&) [with T = {anonymous}::Big_t<int>; typename std::enable_if<folly::detail::ModelsInterface<T, I>::value, int>::type <anonymous> = 0; I = folly::poly::ISemiRegular]':
folly/Poly.h:1131:34:   required from here
folly/Poly-inl.h:59:42: error: placement new constructing an object of type 'U' {aka '{anonymous}::Big_t<int>'} and size '40' in a region of type 'std::aligned_storage_t<16>' {aka 'std::aligned_storage<16, 16>::type'} and size '16' [-Werror=placement-new=]
```

Reviewed By: ericniebler

Differential Revision: D13648512

fbshipit-source-id: 3076e7df1022dd4c3bdcc048edbfb30e8f6a99ed
parent 5d53b331
......@@ -56,7 +56,8 @@ inline PolyVal<I>::PolyVal(T&& t) {
!"Dynamic and static exception types don't match. Object would "
"be sliced when storing in Poly.");
if (inSitu<U>()) {
::new (static_cast<void*>(&_data_()->buff_)) U(static_cast<T&&>(t));
auto const buff = static_cast<void*>(&_data_()->buff_);
::new (buff) U(static_cast<T&&>(t));
} else {
_data_()->pobj_ = new U(static_cast<T&&>(t));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment