Skip to content

Add missing typename in IValue tuple SFINAE for clang-15 - #195671

Closed
huydhn wants to merge 1 commit into
gh/huydhn/58/basefrom
gh/huydhn/58/head
Closed

huydhn wants to merge 1 commit into
gh/huydhn/58/basefrom
gh/huydhn/58/head

Conversation

@huydhn

@huydhn huydhn commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Forward fix for D117882908 (#194977), which broke every
arvr/ovrsource build that depends on xplat/caffe2:ATen_lib_ovrsource:

xplat/caffe2/aten/src/ATen/core/ivalue.h:516:18: error: missing 'typename' prior to
  dependent type name 'enable_if_ivalue_compatible<Args...>::type'
xplat/caffe2/aten/src/ATen/core/ivalue_inl.h:1959:16: error: missing 'typename' prior to
  dependent type name 'IValue::enable_if_ivalue_compatible<Args...>::type'
3 errors generated.

That diff factored the tuple-constructor SFINAE into a new alias member:

template <typename... Ts>
using enable_if_ivalue_compatible = std::enable_if<...>;   // enable_if, not enable_if_t

and uses it as typename = enable_if_ivalue_compatible<Args...>::type. Since
the alias expands to std::enable_if<...>, ::type is a dependent name and
needs the typename disambiguator.

C++20's P0634R3 ("Down with typename!") makes typename optional in exactly
this position -- the default argument of a type template parameter -- which is
why this compiled everywhere the change was tested. This is not a language
version difference: both fbcode and arvr build caffe2 at -std=gnu++20. It is
a compiler version difference. fbcode uses clang-21, while ATen_lib_ovrsource
under arvr/mode/platform010/* pins clang-15 (see the
x86_64-clang-dev-platform010 platform in
arvr/tools/build_defs/config/platform/linux/generated.bzl), and clang did not
implement P0634R3 until 16.

Add the typename disambiguator at the three use sites. It is well formed in
every standard from C++11 on, so it is also accepted by the newer compilers
that already build the current form.

The SFINAE predicate itself is left alone. Rewriting
!disjunction_v<is_lvalue_reference<Args>..., negation<is_constructible<IValue, Args>>...>
as conjunction<negation<is_lvalue_reference<Ts>>..., is_constructible<IValue, Ts>...>
is a correct De Morgan transform and preserves the short-circuit ordering that
keeps is_constructible<IValue, T> from being instantiated on reference types.

xplat/caffe2 is updated to keep it in sync with fbcode/caffe2.

This should also go upstream to #194977, since OSS CI will hit
the same error on any clang-15 build.

Differential Revision: D118389865

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195671

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 2 Pending

As of commit 90fd42a with merge base b543bc5 (image):
💚 Looks good so far! There are no failures yet. 💚

GREEN LIGHT - PR approved to be merged without human review:

Purely a C++ syntax fix: adds the `typename` disambiguator to the three uses of
the dependent name `enable_if_ivalue_compatible<Args...>::type`
(aten/src/ATen/core/ivalue.h:516,520 and ivalue_inl.h:1877), which is required
pre-C++20/clang-15 since the alias at ivalue.h:509 expands to `std::enable_if`,
not `enable_if_t`. Semantically identical to the current form and well-formed
from C++11 on, so no behavior change and no test coverage needed; the
out-of-line constructor definitions at ivalue_inl.h:2137/2142 use an unnamed
`typename /* Enable */` and still match the declarations. Grep confirms no
remaining use of the alias lacks the disambiguator.

reason: clean
Reviewed commit: 90fd42a

Inference job

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 2, 2026
@Skylion007 Skylion007 added the topic: not user facing topic category label Sep 2, 2026
@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
)

Forward fix for D117882908 (pytorch#194977), which broke every
arvr/ovrsource build that depends on `xplat/caffe2:ATen_lib_ovrsource`:

```
xplat/caffe2/aten/src/ATen/core/ivalue.h:516:18: error: missing 'typename' prior to
  dependent type name 'enable_if_ivalue_compatible<Args...>::type'
xplat/caffe2/aten/src/ATen/core/ivalue_inl.h:1959:16: error: missing 'typename' prior to
  dependent type name 'IValue::enable_if_ivalue_compatible<Args...>::type'
3 errors generated.
```

That diff factored the tuple-constructor SFINAE into a new alias member:

```
template <typename... Ts>
using enable_if_ivalue_compatible = std::enable_if<...>;   // enable_if, not enable_if_t
```

and uses it as `typename = enable_if_ivalue_compatible<Args...>::type`. Since
the alias expands to `std::enable_if<...>`, `::type` is a dependent name and
needs the `typename` disambiguator.

C++20's P0634R3 ("Down with typename!") makes `typename` optional in exactly
this position -- the default argument of a type template parameter -- which is
why this compiled everywhere the change was tested. This is not a language
version difference: both fbcode and arvr build caffe2 at `-std=gnu++20`. It is
a compiler version difference. fbcode uses clang-21, while `ATen_lib_ovrsource`
under `arvr/mode/platform010/*` pins clang-15 (see the
`x86_64-clang-dev-platform010` platform in
`arvr/tools/build_defs/config/platform/linux/generated.bzl`), and clang did not
implement P0634R3 until 16.

Add the `typename` disambiguator at the three use sites. It is well formed in
every standard from C++11 on, so it is also accepted by the newer compilers
that already build the current form.

The SFINAE predicate itself is left alone. Rewriting
`!disjunction_v<is_lvalue_reference<Args>..., negation<is_constructible<IValue, Args>>...>`
as `conjunction<negation<is_lvalue_reference<Ts>>..., is_constructible<IValue, Ts>...>`
is a correct De Morgan transform and preserves the short-circuit ordering that
keeps `is_constructible<IValue, T>` from being instantiated on reference types.

`xplat/caffe2` is updated to keep it in sync with `fbcode/caffe2`.

This should also go upstream to pytorch#194977, since OSS CI will hit
the same error on any clang-15 build.

Differential Revision: [D118389865](https://our.internmc.facebook.com/intern/diff/D118389865/)
Pull Request resolved: pytorch#195671
Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
@github-actions
github-actions Bot deleted the gh/huydhn/58/head branch November 13, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged meta-exported topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants