Repository navigation
Conversation
detail::from_ had three overloads selected by an is_constructible tag. Two of
them are reachable and one is not, but the unreachable one is not merely dead:
being more specialized than the catch-all, it shadows the diagnostic the
catch-all exists to produce.
IValue is constructible from intrusive_ptr<T> whenever T derives from
CustomClassHolder, so custom classes take the true_type overload. What reaches
the intrusive_ptr overload is an intrusive_ptr whose pointee is not a custom
class, and IValue(std::move(x)) does not compile for that either. The result is
that the one case the overload was added for -- the 2019 torchbind prototype,
before the custom-class constructor existed -- now reports
error: call of overloaded 'IValue(...)' is ambiguous
from inside ivalue_inl.h, instead of the message written for it:
You are calling from with a type that it doesn't support, and isn't a
potential custom class (ie: is an intrusive_ptr)
Folding the three into one if constexpr in from() drops the tag, drops the
detail namespace, and lets the static_assert fire where it was meant to.
guts::false_t stays: static_assert(false) in a discarded branch is only
well-formed from C++23, and this builds at C++20.
Test Plan:
```
# custom class and plain scalars still convert
static_assert(std::is_constructible_v<IValue, intrusive_ptr<CustomCls>>);
c10::ivalue::from(c10::make_intrusive<CustomCls>());
c10::ivalue::from(std::string("x"));
c10::ivalue::from(at::Tensor());
# an intrusive_ptr to a non-custom class now names the reason
c10::ivalue::from(c10::make_intrusive<PlainIntrusiveTarget>());
```
Compiled with g++ -std=gnu++20 -fsyntax-only against ivalue.h,
custom_class.h and make_boxed_from_unboxed_functor.h, which cover all three
in-tree callers. The supported conversions compile unchanged; the unsupported
one changes from the ambiguous-constructor error to the static_assert.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195105
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 3e11fb8 with merge base 3d0205b ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Skylion007
approved these changes
Aug 28, 2026
Collaborator
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
orrangetabby17
pushed a commit
to orrangetabby17/pytorch
that referenced
this pull request
Sep 2, 2026
detail::from_ had three overloads selected by an is_constructible tag. The unreachable one (intrusive_ptr<T> + false_type) is more specialized than the catch-all, so it shadows the diagnostic the catch-all exists to produce: calling from with an intrusive_ptr to a non-custom class reports an ambiguous-constructor error instead of the intended static_assert message. Folding the three into one if constexpr in from() drops the tag and the detail namespace, and lets the static_assert fire where it was meant to. Pull Request resolved: pytorch#195105 Approved by: https://github.com/Skylion007
Sanskaaar1
pushed a commit
to Sanskaaar1/pytorch
that referenced
this pull request
Sep 8, 2026
detail::from_ had three overloads selected by an is_constructible tag. The unreachable one (intrusive_ptr<T> + false_type) is more specialized than the catch-all, so it shadows the diagnostic the catch-all exists to produce: calling from with an intrusive_ptr to a non-custom class reports an ambiguous-constructor error instead of the intended static_assert message. Folding the three into one if constexpr in from() drops the tag and the detail namespace, and lets the static_assert fire where it was meant to. Pull Request resolved: pytorch#195105 Approved by: https://github.com/Skylion007
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
detail::from_ had three overloads selected by an is_constructible tag. The unreachable one (intrusive_ptr + false_type) is more specialized than the catch-all, so it shadows the diagnostic the catch-all exists to produce: calling from with an intrusive_ptr to a non-custom class reports an ambiguous-constructor error instead of the intended static_assert message.
Folding the three into one if constexpr in from() drops the tag and the detail namespace, and lets the static_assert fire where it was meant to.