Skip to content

Conversation

@guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Jan 14, 2026

The libstdc++ (GCC >= 15) implements std::span::iterator using a private nested tag type, which makes the iterator non-instantiable by CallFunc-generated wrappers (the return type cannot be named without violating access rules).

To preserve correct Python iteration semantics, this commit suggests to replace begin()/end() for std::span to return a custom pointer-based iterator instead. This avoids relying on std::span::iterator while still providing a real C++ iterator object that CPyCppyy can also wrap and expose via __iter__/__next__.

A unit test is implemented based on the reproducers provided in #18837.

Closes #18837.

@guitargeek guitargeek self-assigned this Jan 14, 2026
@guitargeek guitargeek added bug in:Python Interface experiment Affects an experiment / reported by its software & computimng experts labels Jan 14, 2026
@guitargeek
Copy link
Contributor Author

@sponce To which releases would you need this packported?

@sponce
Copy link

sponce commented Jan 14, 2026

Ideally LCG108 version, so 6.36

The libstdc++ (GCC >= 15) implements `std::span::iterator` using a
private nested tag type, which makes the iterator non-instantiable by
CallFunc-generated wrappers (the return type cannot be named without
violating access rules).

To preserve correct Python iteration semantics, this commit suggests to
replace `begin()`/`end()` for `std::span` to return a custom
pointer-based iterator instead. This avoids relying on
`std::span::iterator` while still providing a real C++ iterator object
that CPyCppyy can also wrap and expose via `__iter__`/`__next__`.

A unit test is implemented based on the reproducers provided in root-project#18837.

Closes root-project#18837.
@github-actions
Copy link

Test Results

    23 files      23 suites   3d 15h 7m 20s ⏱️
 3 809 tests  3 803 ✅   0 💤 6 ❌
80 362 runs  80 237 ✅ 119 💤 6 ❌

For more details on these failures, see this check.

Results for commit 253be89.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug experiment Affects an experiment / reported by its software & computimng experts in:Python Interface priority:high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Calling std::span::begin() broken with gcc15

2 participants