[C++-sig] Re: boost::python::object and stl::map warning

David Abrahams dave at boost-consulting.com
Thu Oct 16 01:11:50 CEST 2003


Cedric Shock wrote:

> To whomever can provide some assistance:

> It compiles with g++ 3.2.2, and will work as expected in python. 
> However, for each of those offending statements it produces a warning like:
> 
> (data.count(oi)):
> warning: cannot pass objects of non-POD type `struct 
> std::_Rb_tree_iterator<std::pair<const boost::python::api::object, 
> boost::python::api::object>, const std::pair<const 
> boost::python::api::object, boost::python::api::object>&, const 
> std::pair<const boost::python::api::object, 
> boost::python::api::object>*>' through `...'; call will abort at runtime
> 
> (data[oi].ptr()):
> warning: cannot pass objects of non-POD type `struct 
> std::_Rb_tree_iterator<std::pair<const boost::python::api::object, 
> boost::python::api::object>, std::pair<const boost::python::api::object, 
> boost::python::api::object>&, std::pair<const 
> boost::python::api::object, boost::python::api::object>*>' through 
> `...'; call will abort at runtime
> 
> 
> This warning usually indicates that something bad has been done with a 
> variable argument function like passing a non-POD type to printf. But it 
> should not be an issue here. std::map is routinely used to deal with 
> non-POD objects, why can't it handle the boost::python::object?

Short answer:  it can.

Long answer: The warning is benign, since the function "invocation" is 
inside sizeof(...) and never actually happens.  The compiler should be 
smarter about this.

Even longer answer:  Turn off the warning; it'll cause problems with 
other parts of Boost.

Still longer answer:  Ok, ok.  Try the enclosed patch ;->

HTH,
Dave
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: object_operators.patch
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20031015/f755ac67/attachment.txt>


More information about the Cplusplus-sig mailing list