mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 16:13:53 +00:00
Merge branch 'master' into smart_holder
This commit is contained in:
commit
6d1026763a
@ -25,7 +25,6 @@
|
|||||||
# pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
|
# pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
|
||||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||||
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
|
||||||
# pragma GCC diagnostic ignored "-Wattributes"
|
# pragma GCC diagnostic ignored "-Wattributes"
|
||||||
# if __GNUC__ >= 7
|
# if __GNUC__ >= 7
|
||||||
# pragma GCC diagnostic ignored "-Wnoexcept-type"
|
# pragma GCC diagnostic ignored "-Wnoexcept-type"
|
||||||
|
@ -23,10 +23,18 @@
|
|||||||
#include "detail/smart_holder_sfinae_hooks_only.h"
|
#include "detail/smart_holder_sfinae_hooks_only.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <new>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914))
|
||||||
|
# define PYBIND11_STD_LAUNDER std::launder
|
||||||
|
# define PYBIND11_HAS_STD_LAUNDER 1
|
||||||
|
#else
|
||||||
|
# define PYBIND11_STD_LAUNDER
|
||||||
|
# define PYBIND11_HAS_STD_LAUNDER 0
|
||||||
|
#endif
|
||||||
#if defined(__GNUG__) && !defined(__clang__)
|
#if defined(__GNUG__) && !defined(__clang__)
|
||||||
# include <cxxabi.h>
|
# include <cxxabi.h>
|
||||||
#endif
|
#endif
|
||||||
@ -125,8 +133,21 @@ protected:
|
|||||||
#if defined(__GNUG__) && __GNUC__ >= 6 && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
#if defined(__GNUG__) && __GNUC__ >= 6 && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
||||||
# pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__GNUG__) && !PYBIND11_HAS_STD_LAUNDER && !defined(__INTEL_COMPILER)
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif
|
||||||
|
// UB without std::launder, but without breaking ABI and/or
|
||||||
|
// a significant refactoring it's "impossible" to solve.
|
||||||
if (!std::is_trivially_destructible<Func>::value)
|
if (!std::is_trivially_destructible<Func>::value)
|
||||||
rec->free_data = [](function_record *r) { ((capture *) &r->data)->~capture(); };
|
rec->free_data = [](function_record *r) {
|
||||||
|
auto data = PYBIND11_STD_LAUNDER((capture *) &r->data);
|
||||||
|
(void) data;
|
||||||
|
data->~capture();
|
||||||
|
};
|
||||||
|
#if defined(__GNUG__) && !PYBIND11_HAS_STD_LAUNDER && !defined(__INTEL_COMPILER)
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
rec->data[0] = new capture { std::forward<Func>(f) };
|
rec->data[0] = new capture { std::forward<Func>(f) };
|
||||||
rec->free_data = [](function_record *r) { delete ((capture *) r->data[0]); };
|
rec->free_data = [](function_record *r) { delete ((capture *) r->data[0]); };
|
||||||
|
Loading…
Reference in New Issue
Block a user