|
10 | 10 |
|
11 | 11 | #pragma once |
12 | 12 |
|
13 | | -#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914)) |
14 | | -# define PYBIND11_STD_LAUNDER std::launder |
15 | | -# define PYBIND11_HAS_STD_LAUNDER 1 |
16 | | -#else |
17 | | -# define PYBIND11_STD_LAUNDER |
18 | | -# define PYBIND11_HAS_STD_LAUNDER 0 |
19 | | -#endif |
20 | | - |
21 | 13 | #if defined(__INTEL_COMPILER) |
22 | 14 | # pragma warning push |
23 | 15 | # pragma warning disable 68 // integer conversion resulted in a change of sign |
|
43 | 35 | # pragma GCC diagnostic ignored "-Wunused-but-set-parameter" |
44 | 36 | # pragma GCC diagnostic ignored "-Wunused-but-set-variable" |
45 | 37 | # pragma GCC diagnostic ignored "-Wmissing-field-initializers" |
46 | | -# if !PYBIND11_HAS_STD_LAUNDER |
47 | | -# pragma GCC diagnostic ignored "-Wstrict-aliasing" |
48 | | -# endif |
49 | 38 | # pragma GCC diagnostic ignored "-Wattributes" |
50 | 39 | # if __GNUC__ >= 7 |
51 | 40 | # pragma GCC diagnostic ignored "-Wnoexcept-type" |
@@ -162,7 +151,20 @@ class cpp_function : public function { |
162 | 151 | # pragma GCC diagnostic pop |
163 | 152 | #endif |
164 | 153 | if (!std::is_trivially_destructible<Func>::value) |
| 154 | +#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914)) |
| 155 | +# define PYBIND11_STD_LAUNDER std::launder |
| 156 | +# define PYBIND11_HAS_STD_LAUNDER 1 |
| 157 | +#else |
| 158 | +# define PYBIND11_STD_LAUNDER |
| 159 | +# define PYBIND11_HAS_STD_LAUNDER 0 |
| 160 | +# pragma GCC diagnostic push |
| 161 | +# pragma GCC diagnostic ignored "-Wstrict-aliasing" |
| 162 | +#endif |
| 163 | + |
165 | 164 | rec->free_data = [](function_record *r) { PYBIND11_STD_LAUNDER((capture *) &r->data)->~capture(); }; |
| 165 | +#if !PYBIND11_HAS_STD_LAUNDER |
| 166 | +# pragma GCC diagnostic pop |
| 167 | +#endif |
166 | 168 | } else { |
167 | 169 | rec->data[0] = new capture { std::forward<Func>(f) }; |
168 | 170 | rec->free_data = [](function_record *r) { delete ((capture *) r->data[0]); }; |
|
0 commit comments