1. Dec 16, 2023
  2. Dec 15, 2023
  3. Dec 14, 2023
  4. Dec 13, 2023
  5. Dec 07, 2023
  6. Dec 06, 2023
  7. Dec 02, 2023
  8. Nov 30, 2023
  9. Nov 28, 2023
  10. Nov 16, 2023
  11. Nov 09, 2023
    • Ralf W. Grosse-Kunstleve's avatar
      c6e71cf7
    • Ralf W. Grosse-Kunstleve's avatar
      Fix a long-standing bug in the handling of Python multiple inheritance (#4762) · e250155a
      Ralf W. Grosse-Kunstleve authored
      * Equivalent of https://github.com/google/clif/commit/5718e4d0807fd3b6a8187dde140069120b81ecef
      
      * Resolve clang-tidy errors.
      
      * Moving test_PPCCInit() first changes the behavior!
      
      * Resolve new Clang dev C++11 errors:
      
      ```
      The CXX compiler identification is Clang 17.0.0
      ```
      
      ```
      pytypes.h:1615:23: error: identifier '_s' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
      ```
      
      ```
      cast.h:1380:26: error: identifier '_a' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
      ```
      
      * Resolve gcc 4.8.5 error:
      
      ```
      pytypes.h:1615:12: error: missing space between '""' and suffix identifier
      ```
      
      * Specifically exclude `__clang__`
      
      * Snapshot of debugging code (does NOT pass pre-commit checks).
      
      * Revert "Snapshot of debugging code (does NOT pass pre-commit checks)."
      
      This reverts commit 1d4f9ff2632b32ddcb0dc7ecd0ab7a4ce4c15a4e.
      
      * [ci skip] Order Dependence Demo
      
      * Revert "[ci skip] Order Dependence Demo"
      
      This reverts commit d37b5409d4e5b835620ccbb321a4e1ba89af315c.
      
      * One way to deal with the order dependency issue. This is not the best way, more like a proof of concept.
      
      * Move test_PC() first again.
      
      * Add `all_type_info_add_base_most_derived_first()`, use in `all_type_info_populate()`
      
      * Revert "One way to deal with the order dependency issue. This is not the best way, more like a proof of concept."
      
      This reverts commit eb09c6c1b978208ceee40f05bbe75491b6ff8ad6.
      
      * clang-tidy fixes (automatic)
      
      * Add `is_redundant_value_and_holder()` and use to avoid forcing `__init__` overrides when they are not needed.
      
      * Streamline implementation and avoid unsafe `reinterpret_cast<instance *>()` introduced with PR #2152
      
      The `reinterpret_cast<instance *>(self)` is unsafe if `__new__` is mocked,
      which was actually found in the wild: the mock returned `None` for `self`.
      This was inconsequential because `inst` is currently cast straight back to
      `PyObject *` to compute `all_type_info()`, which is empty if `self` is not
      a pybind11 `instance`, and then `inst` is never dereferenced. However, the
      unsafe detour through `instance *` is easily avoided and the updated
      implementation is less prone to accidents while debugging or refactoring.
      
      * Fix actual undefined behavior exposed by previous changes.
      
      It turns out the previous commit message is incorrect, the `inst` pointer is actually dereferenced, in the `value_and_holder` ctor here:
      
      https://github.com/pybind/pybind11/blob/f3e0602802c7840992c97f4960515777cad6a5c7/include/pybind11/detail/type_caster_base.h#L262-L263
      
      ```
      259     // Main constructor for a found value/holder:
      260     value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
      261         : inst{i}, index{index}, type{type},
      262           vh{inst->simple_layout ? inst->simple_value_holder
      263                                  : &inst->nonsimple.values_and_holders[vpos]} {}
      ```
      
      * Add test_mock_new()
      
      * Experiment: specify indirect bases
      
      * Revert "Experiment: specify indirect bases"
      
      This reverts commit 4f90d85f9fc15290d6be54d5ae9417bd131b84d9.
      
      * Add `all_type_info_check_for_divergence()` and some tests.
      
      * Call `all_type_info_check_for_divergence()` also from `type_caster_generic::load_impl<>`
      
      * Resolve clang-tidy error:
      
      ```
      include/pybind11/detail/type_caster_base.h:795:21: error: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty,-warnings-as-errors]
                      if (matching_bases.size() != 0) {
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
                          !matching_bases.empty()
      ```
      
      * Revert "Resolve clang-tidy error:"
      
      This reverts commit df27188dc6d6cf333145755543f56b2f6657aa5e.
      
      * Revert "Call `all_type_info_check_for_divergence()` also from `type_caster_generic::load_impl<>`"
      
      This reverts commit 5f5fd6a68e3cff1726628f6dea8e1c0754636a23.
      
      * Revert "Add `all_type_info_check_for_divergence()` and some tests."
      
      This reverts commit 0a9599f775bfd3ca196c5e23a3fcf2890cbf6e82.
      e250155a
    • Ralf W. Grosse-Kunstleve's avatar
      b9c17cfc
    • Ralf W. Grosse-Kunstleve's avatar
  12. Nov 08, 2023
  13. Nov 07, 2023
  14. Nov 06, 2023
  15. Nov 04, 2023
  16. Nov 03, 2023
  17. Nov 02, 2023
    • Ralf W. Grosse-Kunstleve's avatar
      [smart_holder] Bug fix: `std::unique_ptr` deleter needs to be copied. (#4850) · 55105fbe
      Ralf W. Grosse-Kunstleve authored
      * Store `std::function<void (void *)>` del_fun; in `guarded_delete`
      
      * Specialize the simple common case.
      
      Using a `union` is complicated: https://en.cppreference.com/w/cpp/language/union
      
      > If members of a union are classes with user-defined constructors and destructors, to switch the active member, explicit destructor and placement new are generally needed:
      
      Using `std::variant` increases compile-time overhead.
      
      It is currently unclear how much these effects matter in practice: optimization left for later.
      
      * Add one test case (more later).
      
      * Add `const` to resolve clang-tidy error.
      
      ```
      -- The CXX compiler identification is Clang 15.0.7
      
      /usr/bin/cmake -E __run_co_compile --tidy="/usr/bin/clang-tidy;--use-color;--warnings-as-errors=*;--extra-arg-before=--driver-mode=g++" --source=/__w/pybind11/pybind11/tests/test_class_sh_inheritance.cpp -- /usr/bin/c++ -DPYBIND11_ENABLE_TYPE_CASTER_ODR_GUARD_IF_AVAILABLE -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -I/__w/pybind11/pybind11/include -isystem /usr/include/python3.9 -isystem /__w/pybind11/pybind11/build/_deps/eigen-src -Os -DNDEBUG -fPIC -fvisibility=hidden -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wundef -Wnon-virtual-dtor -flto=thin -std=c++17 -o CMakeFiles/pybind11_tests.dir/test_class_sh_inheritance.cpp.o -c /__w/pybind11/pybind11/tests/test_class_sh_inheritance.cpp
      /__w/pybind11/pybind11/tests/pure_cpp/smart_holder_poc_test.cpp:264:30: error: pointer parameter 'raw_ptr' can be pointer to const [readability-non-const-parameter,-warnings-as-errors]
              new int(19), [](int *raw_ptr) { delete raw_ptr; });
                                   ^
                              const
      ```
      
      * Introduce `struct custom_deleter` to ensure the deleter is moved as desired (the lambda function only captures a reference, which can become dangling).
      
      * Resolve helpful clang-tidy errors.
      
      ```
      /usr/bin/cmake -E __run_co_compile --tidy="/usr/bin/clang-tidy;--use-color;--warnings-as-errors=*;--extra-arg-before=--driver-mode=g++" --source=/__w/pybind11/pybind11/tests/test_class.cpp -- /usr/bin/c++ -DPYBIND11_ENABLE_TYPE_CASTER_ODR_GUARD_IF_AVAILABLE -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -I/__w/pybind11/pybind11/include -isystem /usr/include/python3.9 -isystem /__w/pybind11/pybind11/build/_deps/eigen-src -Os -DNDEBUG -fPIC -fvisibility=hidden -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wundef -Wnon-virtual-dtor -flto=thin -std=c++17 -o CMakeFiles/pybind11_tests.dir/test_class.cpp.o -c /__w/pybind11/pybind11/tests/test_class.cpp
      /__w/pybind11/pybind11/include/pybind11/detail/smart_holder_poc.h:114:5: error: single-argument constructors must be marked explicit to avoid unintentional implicit conversions [google-explicit-constructor,-warnings-as-errors]
          custom_deleter(D &&deleter) : deleter{std::move(deleter)} {}
          ^
          explicit
      /__w/pybind11/pybind11/include/pybind11/detail/smart_holder_poc.h:120:76: error: forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference,-warnings-as-errors]
          return guarded_delete(std::function<void(void *)>(custom_deleter<T, D>(std::move(uqp_del))),
                                                                                 ^~~~~~~~~
                                                                                 std::forward<D>
      ```
      
      * Workaround for gcc 4.8.5, clang 3.6
      
      * Transfer reduced test here.
      
      Reduced from a PyCLIF use case in the wild by @wangxf123456 (internal change cl/565476030).
      
      * Add missing include (clangd Include Cleaner)
      
      * Change `std::move` to `std::forward` as suggested by @iwanders.
      
      * Add missing includes (clangd Include Cleaner)
      
      * Use new `PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP` to exclude `smart_holder::as_unique_ptr` method from production code.
      
      * Systematically add `PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP` to mark code that is not used from production code. Add comment to explain.
      
      * Very simple experiment related to https://github.com/pybind/pybind11/pull/4850#issuecomment-1789780676
      
      Does the `PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP` define have anything to do with it?
      
      * Revert "Very simple experiment related to https://github.com/pybind/pybind11/pull/4850#issuecomment-1789780676"
      
      This reverts commit fe59369f408d354edef16e3d40e2f90d9c2a9ba8.
      55105fbe
  18. Nov 01, 2023
  19. Oct 27, 2023