fix: workaround NVCC parse failure in cast_op#4893
Conversation
There is a bug in some CUDA versions (observed in CUDA 12.1 and 11.7 w/ GCC 12.2), that makes `cast_op` fail to compile: `cast.h:45:120: error: expected template-name before ‘<’ token` Defining the nested type as an alias and using it allows this to work without any change in semantics. Fixes pybind#4606
| template <typename T> | ||
| typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) { | ||
| return caster.operator typename make_caster<T>::template cast_op_type<T>(); | ||
| using result_t = typename make_caster<T>::template cast_op_type<T>; |
There was a problem hiding this comment.
Could you please add a comment at the end of the line, e.g.
// See PR #4893.
Also below.
In case someone later is considering inlining result_t again, they can easily know why it's here.
|
If someone has this problem and cannot update pybind11 for any reason, note that, to me at least, this doesn't happen with GCC 11 as host compiler. e.g. |
|
not sure, how can one check if this PR went into a tagged version (not master) of pybind11 ? |
There was no release of any kind in the time after this PR was merged. |
Github offers a nice way: Open the merge commit found in the PR (message like " merged commit 3414c56 into pybind:master") and Github will show the branches and tags this is contained in between the commit message and author(s). Right now it only shows the master branch but once a tag is out, that would be shown too unless the tag is from a different branch. In the meantime you can pick this PR as a patch and apply it manully by appending |
cast_opcast_op
There is a bug in some CUDA versions (observed in CUDA 12.1 and 11.7 w/ GCC 12.2), that makes
cast_opfail to compile:cast.h:45:120: error: expected template-name before ‘<’ tokenDefining the nested type as an alias and using it allows this to work without any change in semantics.
Fixes #4606
The alternative using a
static_castor similar fails due to ambiguity with theconst Foo&andFoo&operators (one of the tests)Suggested changelog entry: