mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
Merge pull request #272 from jagerman/fix-gcc6-placement-new-warning
Fix gcc6 placement new warning
This commit is contained in:
commit
c2ee3f52b5
@ -82,7 +82,14 @@ protected:
|
|||||||
|
|
||||||
/* Store the capture object directly in the function record if there is enough space */
|
/* Store the capture object directly in the function record if there is enough space */
|
||||||
if (sizeof(capture) <= sizeof(rec->data)) {
|
if (sizeof(capture) <= sizeof(rec->data)) {
|
||||||
|
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wplacement-new"
|
||||||
|
#endif
|
||||||
new ((capture *) &rec->data) capture { std::forward<Func>(f) };
|
new ((capture *) &rec->data) capture { std::forward<Func>(f) };
|
||||||
|
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
if (!std::is_trivially_destructible<Func>::value)
|
if (!std::is_trivially_destructible<Func>::value)
|
||||||
rec->free_data = [](detail::function_record *r) { ((capture *) &r->data)->~capture(); };
|
rec->free_data = [](detail::function_record *r) { ((capture *) &r->data)->~capture(); };
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user