[LLVMbugs] [Bug 17917] New: missing check that deduction actually succeeded when partially ordering function templates

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 13 13:03:26 PST 2013


            Bug ID: 17917
           Summary: missing check that deduction actually succeeded when
                    partially ordering function templates
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


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 {};


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;


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;


Per, 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 that X == Foo<T> for some T. Clearly,
neither of these implies the other.

Practically, we're missing a call to something like
FinishTemplateArgumentDeduction in the FunctionTemplateDecl form of
isAtLeastAsSpecializedAs: we fail to check that the deduction produces template
arguments that make the deduced A compatible with the original A (as required
by [temp.deduct.type]p1).

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131113/73e7afdb/attachment.html>

More information about the llvm-bugs mailing list