GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix static object initialization under Visual Studio 2017 (#208) · gladk/python@65bfec2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • include/boost/python/detail
    • caller.hpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎include/boost/python/detail/caller.hpp‎

Copy file name to clipboardExpand all lines: include/boost/python/detail/caller.hpp
+22-9Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,23 @@ struct converter_target_type <void_result_to_python >
109109
return 0;
110110
}
111111
};
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+
112129
#endif
113130

114131

@@ -229,16 +246,12 @@ struct caller_arity<N>
229246
{
230247
const signature_element * sig = detail::signature<Sig>::elements();
231248
#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>();
232253

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 };
242255
#else
243256
py_func_sig_info res = {sig, sig };
244257
#endif

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.