-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
include/pybind11/cast.h
Outdated
@@ -42,13 +42,15 @@ using make_caster = type_caster<intrinsic_t<type>>; | |||
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_op
cast_op
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 #4606
The alternative using a
static_cast
or similar fails due to ambiguity with theconst Foo&
andFoo&
operators (one of the tests)Suggested changelog entry: