Skip to content

[BUG] Possible issue in C++17 mode? #2856

Closed

Description

@henryiii

Issue description

I have a class A and a subclass B, both registered by pybind11.

When enabling C++17 mode, I had to replace B::size with a lambda function, as pybind11 suddenly started tying this to "A", which was previously correctly using the correct thing in C++14 mode. Seems to happen on both GCC and Clang.

Reproducible example code

Might try to build a minimal example later , just wanted to get this in so I don't forget. Change to make tests pass here: scikit-hep/boost-histogram@6c93370 "boolean" is my subclass, and "integer_none" is the previously registered parent. scikit-hep/boost-histogram#502

Activity

  1. bstaletic commented on Feb 11, 2021

    @bstaletic
    Collaborator

    Is B::size marked noexcept? If it is, that's a known issue and requires rewriting some of pybind's custom type traits. Also, if my assumption is correct, this is a duplicate of #2234 and #2666

  2. bstaletic commented on Feb 24, 2021

    @bstaletic
    Collaborator

    Assuming I have not missed anything, these are the things that need updating:

    • cpp_function
    • class_::def_buffer
    • detail::remove_class
    • detail::initimpl::factory

    The first three are easy. The initimpl::factory is related to py::init as the return type. I don't know if it would break anything else, but initimpl::factory could be fixed by stripping noexcept in py::detail::function_signature_t.

    EDIT: There's also

    • method_adaptor
    • vectorize
  3. Skylion007 commented on Mar 28, 2023

    @Skylion007
    Collaborator

    detail::remove_class has been dealt with partially in #4593 . That turned out to be enough to allow for noexcept lambdas.

  4. henryiii commented on Nov 12, 2026

    @henryiii
    CollaboratorAuthor

    🤖 AI text below 🤖

    Fixed by #5992 (in v3.1.0). method_adaptor now rebinds noexcept member function pointers from a base class to the derived class, so &B::size binds with B as self in C++17. Duplicate of #2234.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions