@@ -109,6 +109,23 @@ struct converter_target_type <void_result_to_python > |
109 | 109 | return 0; |
110 | 110 | } |
111 | 111 | }; |
| 112 | + |
| 113 | +// Generation of ret moved from caller_arity<N>::impl::signature to here due to "feature" in MSVC 15.7.2 with /O2 |
| 114 | +// which left the ret uninitialized and caused segfaults in Python interpreter. |
| 115 | +template<class Policies, class Sig> const signature_element* get_ret() |
| 116 | +{ |
| 117 | + typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type<Sig>::type rtype; |
| 118 | + typedef typename select_result_converter<Policies, rtype>::type result_converter; |
| 119 | + |
| 120 | + static const signature_element ret = { |
| 121 | + (is_void<rtype>::value ? "void" : type_id<rtype>().name()) |
| 122 | + , &detail::converter_target_type<result_converter>::get_pytype |
| 123 | + , boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value |
| 124 | + }; |
| 125 | + |
| 126 | + return &ret; |
| 127 | +}; |
| 128 | + |
112 | 129 | #endif |
113 | 130 |
|
114 | 131 |
|
@@ -229,16 +246,12 @@ struct caller_arity<N> |
229 | 246 | { |
230 | 247 | const signature_element * sig = detail::signature<Sig>::elements(); |
231 | 248 | #ifndef BOOST_PYTHON_NO_PY_SIGNATURES |
| 249 | + // MSVC 15.7.2, when compiling to /O2 left the static const signature_element ret, |
| 250 | + // originally defined here, uninitialized. This in turn led to SegFault in Python interpreter. |
| 251 | + // Issue is resolved by moving the generation of ret to separate function in detail namespace (see above). |
| 252 | + const signature_element * ret = detail::get_ret<Policies, Sig>(); |
232 | 253 |
|
233 | | - typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type<Sig>::type rtype; |
234 | | - typedef typename select_result_converter<Policies, rtype>::type result_converter; |
235 | | - |
236 | | - static const signature_element ret = { |
237 | | - (is_void<rtype>::value ? "void" : type_id<rtype>().name()) |
238 | | - , &detail::converter_target_type<result_converter>::get_pytype |
239 | | - , boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value |
240 | | - }; |
241 | | - py_func_sig_info res = {sig, &ret }; |
| 254 | + py_func_sig_info res = {sig, ret }; |
242 | 255 | #else |
243 | 256 | py_func_sig_info res = {sig, sig }; |
244 | 257 | #endif |
|