-
Notifications
You must be signed in to change notification settings - Fork 13.4k
missing check that deduction actually succeeded when partially ordering function templates #18291
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
Comments
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
@llvm/issue-subscribers-clang-frontend Author: None (ec04fc15-fa35-46f2-80e1-5d271f2ef708)
| | |
| --- | --- |
| Bugzilla Link | [17917](https://llvm.org/bz17917) |
| Version | trunk |
| OS | Linux |
| CC | @DougGregor |
Extended DescriptionConsider: template<bool> struct enable_if { typedef void type; };
template <class T> class Foo {};
template <class X> constexpr bool check() { return true; }
template <class X, class Enable = void> struct Bar {};
#ifdef FUNCTION_ORDERING
template<class X> void func(Bar<X, typename enable_if<check<X>()>::type>) { }
template<class T> int func(Bar<Foo<T>>) { return 0; }
int (*p)(Bar<Foo<int>>) = func;
#else
template<typename X> struct Bar<X, typename enable_if<check<X>()>::type> {};
template<typename X> struct Bar<Foo<X>> { typedef int type; };
Bar<Foo<int>>::type bar;
#endif Per 14.5.5.2/1, the class template partial specialization partial ordering and the function template partial ordering above should behave exactly the same. But they don't: for clang, gcc, and edg, the Morally, both cases should be rejected; this is ambiguous because the first template has the constraint that Practically, we're missing a call to something like |
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
…mplates This makes partial ordering of function templates consistent with other entities. Fixes #18291
This fixes a bug in #18291, that was reported in the PR. Since this is a bug fix for a patch that was never released, no entries are added to the changelog.
Extended Description
Consider:
Per 14.5.5.2/1, the class template partial specialization partial ordering and the function template partial ordering above should behave exactly the same. But they don't: for clang, gcc, and edg, the
FUNCTION_ORDERING
case is accepted and the other (class ordering) case is rejected.Morally, both cases should be rejected; this is ambiguous because the first template has the constraint that
enable_if<check<X>()>::type == void
, and the second template has the constraint thatX == Foo<T>
for someT
. Clearly, neither of these implies the other.Practically, we're missing a call to something like
FinishTemplateArgumentDeduction
in theFunctionTemplateDecl
form ofisAtLeastAsSpecializedAs
: we fail to check that the deduction produces template arguments that make the deducedA
compatible with the originalA
(as required by [temp.deduct.type]p1).The text was updated successfully, but these errors were encountered: