← 输入框|github.com|刷新
Skip to content

boost::python::make_setter(&X::y) no longer compiles #39

Closed

Description

@jwakely

This trivial example, similar to the examples in the Boost.Python documentation, compiled with 1.58 but doesn't with 1.59 (using various versions of GCC and Clang):

#include <boost/python.hpp>

struct X { int y; };

int main()
{
  boost::python::make_setter(&X::y);
}

The relevant error is:

/usr/local/boost-1.59.0/include/boost/python/data_members.hpp:303:15: note: candidate: boost::python::api::object boost::python::make_setter(D&) [with D = int X::*] <near match>

    inline object make_setter(D& x)
                  ^

/usr/local/boost-1.59.0/include/boost/python/data_members.hpp:303:15: note: conversion of argument 1 would be ill-formed:

prog.cc:7:37: error: invalid initialization of non-const reference of type 'int X::*&' from an rvalue of type 'int X::*'

     boost::python::make_setter(&X::y);
                                     ^

Activity

  1. jwakely commented on Sep 2, 2015

    @jwakely
    ContributorAuthor

    This was caused by 42e7d7b which broke the preprocessor condition for make_setter by inverting the sense of the test. There was a later change in 590b788 but it didn't restore the old behaviour.

  2. added a commit that references this issue on Sep 2, 2015
    f410fbd
  3. afh commented on Sep 15, 2015

    @afh

    What intermediate solution can projects (e.g. ledger) use to fix this until the next release of boost python?

  4. jwakely commented on Sep 15, 2015

    @jwakely
    ContributorAuthor

    You could define the "missing" overload in your own code:

    #if BOOST_VERSION == 105900
    // Fix for https://github.com/boostorg/python/issues/39
    namespace boost { namespace python {
    template <class D>
    inline object make_setter(D const& x)
    {
        return detail::make_setter(x, default_call_policies(), is_member_pointer<D>(), 0);
    }
    }}
    #endif
    
  5. afh commented on Sep 15, 2015

    @afh

    Thank you for your reply. I already tried that to no avail, which I find quite odd.
    I tried adding the "missing" overload in different places in the code, but still see errors like:

    ../src/py_amount.cc:131:26: error: no matching function for call to 'make_setter'
                             make_setter(&amount_t::is_initialized))
                             ^~~~~~~~~~~
    /opt/homebrew/include/boost/python/data_members.hpp:303:15: note: candidate function [with D = bool *] not viable: no known conversion from 'bool *' to 'bool *&' for 1st argument
    inline object make_setter(D& x)
                  ^
    /opt/homebrew/include/boost/python/data_members.hpp:291:15: note: candidate function template not viable: requires 2 arguments, but 1 was provided
    inline object make_setter(D& x, Policies const& policies)
    
  6. jwakely commented on Sep 15, 2015

    @jwakely
    ContributorAuthor

    Looks like you didn't declare the overload everywhere it's needed, since it's not listed as a candidate function.

  7. stefanseefeld commented on Sep 15, 2015

    @stefanseefeld
    Member

    (As usual, it might help to put together a minimal test case and share that. Otherwise it's hard to help just by second-guessing.)

  8. afh commented on Sep 15, 2015

    @afh

    @stefanseefeld The #40 fix works just fine. Yet I would like to make the project aware that boost python 1.59 has an issue and address that with a workaround within the project.

  9. stefanseefeld commented on Sep 15, 2015

    @stefanseefeld
    Member

    Yes, I understand. But even if you ask for help on your own code, it's hard to do so without seeing the actual code. (And often enough putting together a test case might in itself reveal the problem, so it's a good strategy anyhow. :-))

  10. jwakely commented on Sep 15, 2015

    @jwakely
    ContributorAuthor

    Be aware that Fedora rawhide (which will become Fedora 24) has a patched version of Boost 1.59.0 which includes the fix, so putting a workaround in the project might conflict with that patched version of Boost.

  11. afh commented on Sep 15, 2015

    @afh

    I'm afraid I may have had an unclean environment, in which I tested. With a fresh workspace and merely the proposed changes by @jwakely it compiles just fine.

    @stefanseefeld Thanks for the advice. I'll remember it for next time.

  12. afh commented on Sep 15, 2015

    @afh

    @jwakely Thanks for the heads up. How would such an issue be addressed best?

    • Within the project's configuration step (for ledger that would be CMake)?
    • Add the fix for the "majority" of users and have it fail for the others?
    • Not all?
    • Deliver a patch that users can apply manually?
  13. jwakely commented on Sep 15, 2015

    @jwakely
    ContributorAuthor

    Within the project's configuration step (for ledger that would be CMake)?

    Yes, I would add an autoconf / cmake test and only add the missing overload if needed.

  14. stefanseefeld commented on Sep 15, 2015

    @stefanseefeld
    Member

    (This is entirely off-topic, but anyhow: Given that "#if BOOST_VERSION == 105900" appears to be the condition under which you'll need this patch, there is really nothing to configure for. Just put the above patch from @jwakely into your source code wherever needed and move on.)

  15. 16 remaining items

  16. added 2 commits that reference this issue on Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions