]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/python/detail/caller.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / python / detail / caller.hpp
index 1bd30bfb5a0634a49fa18d1312f107cb62022717..557359f5f523f13ae8636329160fdfd5b79bea63 100644 (file)
@@ -109,6 +109,23 @@ struct converter_target_type <void_result_to_python >
         return 0;
     }
 };
+
+// Generation of ret moved from caller_arity<N>::impl::signature to here due to "feature" in MSVC 15.7.2 with /O2
+// which left the ret uninitialized and caused segfaults in Python interpreter.
+template<class Policies, class Sig> const signature_element* get_ret()
+{
+    typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type<Sig>::type rtype;
+    typedef typename select_result_converter<Policies, rtype>::type result_converter;
+
+    static const signature_element ret = {
+        (is_void<rtype>::value ? "void" : type_id<rtype>().name())
+        , &detail::converter_target_type<result_converter>::get_pytype
+        , boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value 
+    };
+
+    return &ret;
+};
+
 #endif
 
     
@@ -229,16 +246,12 @@ struct caller_arity<N>
         {
             const signature_element * sig = detail::signature<Sig>::elements();
 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
+            // MSVC 15.7.2, when compiling to /O2 left the static const signature_element ret, 
+            // originally defined here, uninitialized. This in turn led to SegFault in Python interpreter.
+            // Issue is resolved by moving the generation of ret to separate function in detail namespace (see above).
+            const signature_element * ret = detail::get_ret<Policies, Sig>();
 
-            typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type<Sig>::type rtype;
-            typedef typename select_result_converter<Policies, rtype>::type result_converter;
-
-            static const signature_element ret = {
-                (is_void<rtype>::value ? "void" : type_id<rtype>().name())
-                , &detail::converter_target_type<result_converter>::get_pytype
-                , boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value 
-            };
-            py_func_sig_info res = {sig, &ret };
+            py_func_sig_info res = {sig, ret };
 #else
             py_func_sig_info res = {sig, sig };
 #endif