mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 15:12:01 +00:00
Disable -Wplacement-new warning false alarm
GCC-6 adds a -Wplacement-new warning that warns for placement-new into a space that is too small, which is sometimes being triggered here (e.g. example5 always generates the warning under g++-6). It's a false warning, however: the line immediately before just checked the size, and so this line is never going to actually be reached in the cases where the GCC warning is being triggered. This localizes the warning disabling just to this one spot as there are other placement-new uses in pybind11 where this warning could warn about legitimate future problems.
This commit is contained in:
parent
4be37c17d7
commit
cae0e00947
@ -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<Func>(f) };
|
||||
#if defined(__GNUG__) && !defined(__clang__)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
if (!std::is_trivially_destructible<Func>::value)
|
||||
rec->free_data = [](detail::function_record *r) { ((capture *) &r->data)->~capture(); };
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user