Skip to content

Resolve ambiguous factory specialization with nvcc+GCC#6011

Merged
rwgk merged 1 commit intopybind:masterfrom
n01r:fix/cuda-gcc-factory-ambiguity
Mar 24, 2026
Merged

Resolve ambiguous factory specialization with nvcc+GCC#6011
rwgk merged 1 commit intopybind:masterfrom
n01r:fix/cuda-gcc-factory-ambiguity

Conversation

@n01r
Copy link
Copy Markdown
Contributor

@n01r n01r commented Mar 24, 2026

Description

Fixes #5565 and BLAST-WarpX/warpx#6702.

When compiling with nvcc + GCC 14, the single-factory specialization
factory<Func, void_type (*)(), Return(Args...)> and the dual-factory
specialization factory<CFunc, AFunc, CReturn(CArgs...), AReturn(AArgs...)>
are considered ambiguous by the compiler. The single-factory spec only
specifies 3 of 4 template parameters (the 4th defaults to void_type()),
while the dual-factory spec decomposes all 4 — so neither is strictly
more specialized than the other.

The fix explicitly specifies the 4th parameter as void_type() in the
single-factory specialization, making it unambiguously more specialized.

Suggested changelog entry:

  • Fixed ambiguous factory template specialization in detail/init.h
    that caused compilation failure with nvcc + GCC 14.
    #5565 <https://github.com/pybind/pybind11/issues/5565>_

Explicitly specify the 4th template parameter in the
single-factory partial specialization of `factory` to
disambiguate it from the dual-factory specialization
when compiled with nvcc + GCC 14. Fixes pybind#5565.

Co-Authored-By: Oz <oz-agent@warp.dev>
Copy link
Copy Markdown
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to my agent :-)

Verdict: One-line fix, good explanatory comment, fixes a real compilation issue on CUDA + GCC 14. The commit is co-authored with an AI agent (Oz/Warp). Looks straightforward and correct.

@rwgk rwgk merged commit 2d1723c into pybind:master Mar 24, 2026
89 checks passed
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Mar 24, 2026
@n01r n01r deleted the fix/cuda-gcc-factory-ambiguity branch March 24, 2026 04:48
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.

[BUG]: Compiling with enum_ on CUDA + GCC fails

2 participants