Opened 14 years ago

Closed 14 years ago

#1931 closed Bugs (fixed)

Boost.Python headers won't compile with GCC 4.3

Reported by: vbe@… Owned by: Dave Abrahams
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:

Description

To reproduce this bug it is sufficient to compile this program:

#include <boost/python.hpp>

int main(int argc, char argv) {

return 0;

}

The following error is thrown:

../include/boost/python/detail/def_helper.hpp:192: error: declaration of 'typename boost::python::detail::keyword_extract<boost::tuples::tuple<const T1&, const T2&, const T3&, const T4&, boost::python::default_call_policies, boost::python::detail::keywords<0u>, const char*, void (boost::python::detail::not_specified::*)(), boost::tuples::null_type, boost::tuples::null_type> >::result_type boost::python::detail::def_helper<T1, T2, T3, T4>::keywords() const' ../include/boost/python/args_fwd.hpp:35: error: changes meaning of 'keywords' from 'struct boost::python::detail::keywords<0u>'

The reason is that the name 'keyword' is used both for a struct (args_fwd.hpp, line 34) and for a function (detail/def_helper.hpp, line 189) in the same namespace. GCC 4.3 does not allow this.

The fix is simple: rename either the struct or the function.

Change History (4)

comment:1 by vbe@…, 14 years ago

I wanted to submit a patch, but it does not work:

Internal Error

Submission rejected as potential spam (Akismet says content is spam)

comment:2 by anonymous, 14 years ago

FROM http://sourceforge.net/tracker/index.php?func=detail&aid=1968282&group_id=165310&atid=835077 ==================================================================================

This is a bug in boost python, there are similar reports for other projects.

If you want a quick workaround do:

1) /usr/include/boost/python/detail/def_helper.hpp:

line 189: typename keyword_extract<all_t>::result_type keywords() const change to: typename keyword_extract<all_t>::result_type extract_keywords() const

2) /usr/include/boost/python/class.hpp:

line 542: , helper.keywords() change to: , helper.extract_keywords()

line 571: helper.default_implementation(), helper.policies(), helper.keywords()) change to: helper.default_implementation(), helper.policies(), helper.extract_keywords())

comment:3 by soc, 14 years ago

FROM http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html

Name lookup changes

GCC 4.3 by default no longer accepts code such as

template <class _Tp> class auto_ptr {};
template <class _Tp>
struct counted_ptr
{
  auto_ptr<_Tp> auto_ptr();
};

but will issue the diagnostic

error: declaration of 'auto_ptr<_Tp> counted_ptr<_Tp>::auto_ptr()' error: changes meaning of 'auto_ptr' from 'class auto_ptr<_Tp>'

The reference to struct auto_ptr needs to be qualified here, or the name of the member function changed to be unambiguous.

template <class _Tp> class auto_ptr {};
template <class _Tp>
struct counted_ptr
{
  ::auto_ptr<_Tp> auto_ptr();
};

In addition, -fpermissive can be used as a temporary workaround to convert the error into a warning until the code is fixed. Note that then in some case name lookup will not be standard conforming.

comment:4 by Dave Abrahams, 14 years ago

Resolution: fixed
Status: newclosed

As far as I can tell this was fixed in [39434]

Note: See TracTickets for help on using tickets.