diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 3d31b21df..b7833fc60 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -82,7 +82,14 @@ protected: /* Store the capture object directly in the function record if there is enough space */ if (sizeof(capture) <= sizeof(rec->data)) { +#if defined(__GNUG__) && !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wplacement-new" +#endif new ((capture *) &rec->data) capture { std::forward(f) }; +#if defined(__GNUG__) && !defined(__clang__) +# pragma GCC diagnostic pop +#endif if (!std::is_trivially_destructible::value) rec->free_data = [](detail::function_record *r) { ((capture *) &r->data)->~capture(); }; } else {