Skip to content

fix: clear compiler diagnostics in override lookup - #6332

Merged
rwgk merged 3 commits into
pybind:masterfrom
rwgk:rwgk/fix-override-lifetime-ci
Dec 1, 2026
Merged

rwgk merged 3 commits into
pybind:masterfrom
rwgk:rwgk/fix-override-lifetime-ci

Conversation

@rwgk

@rwgk rwgk commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

— codex GPT-6.2-Sol on behalf of Ralf —

Description

The full matrix on #6331 exposed two diagnostics in code that landed via #6249. MSVC reports C4127 when the borrowed lookup makes the if condition constant. Keep the original condition and use the existing warning macros to suppress C4127 within get_object_impl. Use auto for the owner initialized by reinterpret_borrow<object> to satisfy Clang-Tidy.

The last full CI run on #6249 passed on a revision that preceded the lookup refactor. Full CI was deferred for re-review on the final revision, so the compiler checks did not run against that refactor before the merge.

Local validation passed for the existing override lifetime and shared-pointer tests on Python 3.15.2 with GIL and free-threaded (10 tests each), Clang C++11 compilation against Python 3.9 headers, and repository lint. The ready-for-review CI run will cover the affected MSVC and Clang-Tidy jobs.

rwgk added 3 commits December 1, 2026 13:27
Keep the ownership-dependent reference acquisition in the result expression and branch on the returned pointer. This avoids a constant if condition for borrowed lookup while preserving reference acquisition under the instance-map lock. Let the cast deduce the GIL-path owner type for clang-tidy.

Validated the focused override and shared-pointer tests on both Python 3.15 variants, C++11 compilation with Python 3.9 headers, and repository lint.

Assisted-by: Codex:GPT-6.2-Sol
Test an ordinary boolean variable to avoid the MSVC constant-condition warning. Preserve short-circuit evaluation and keep the reference acquisition under the map lock.

Assisted-by: Codex:GPT-6.2-Sol
Restore the original lookup condition and apply the existing C4127 diagnostic macro within a balanced push/pop. The warning settings are restored after get_object_impl.

Assisted-by: Codex:GPT-6.2-Sol
@rwgk
rwgk requested a review from henryiii December 1, 2026 21:54
@rwgk

rwgk commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

— codex GPT-6.2-Sol on behalf of Ralf —

@henryiii I’ll go ahead and merge this to get CI on master green again.

@rwgk
rwgk merged commit 97beb13 into pybind:master Dec 1, 2026
94 checks passed
@github-actions github-actions Bot added the needs changelog Possibly needs a changelog entry label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs changelog Possibly needs a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant