<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - missing check that deduction actually succeeded when partially ordering function templates"
   href="http://llvm.org/bugs/show_bug.cgi?id=17917">17917</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>missing check that deduction actually succeeded when partially ordering function templates
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider:

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 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).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>