<html>
    <head>
      <base href="https://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 --- - poor diagnostics for ambiguous template function instantation"
   href="https://llvm.org/bugs/show_bug.cgi?id=31450">31450</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>poor diagnostics for ambiguous template function instantation
          </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>All
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>compnerd@compnerd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

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

namespace n {
int f(void *);

template <int> int g(void *);

extern template int g<0>(void *);
}

using namespace n;

template <int> int g(void *p) { return 0; }

template int g<0>(void *);

The template function here is ambiguous because we have n::g and ::g.

We diagnose this as:

$ clang -fsyntax-only -std=c++11 /tmp/reduced.cc
/tmp/reduced.cc:13:14: error: partial ordering for explicit instantiation of
'g' is ambiguous
template int g<0>(void *);
             ^
/tmp/reduced.cc:11:20: note: explicit instantiation candidate function template
here [with $0 = 0]
template <int> int g(void *p) { return 0; }
                   ^
/tmp/reduced.cc:4:20: note: explicit instantiation candidate function template
here [with $0 = 0]
template <int> int g(void *);
                   ^
While gcc diagnoses this as:

$ c++ -fsyntax-only -std=c++11 /tmp/reduced.cc
/tmp/reduced.cc:13:14: error: ambiguous template specialization 'g<0>' for 'int
g(void*)'
 template int g<0>(void *);
              ^
/tmp/reduced.cc:11:20: note: candidates are: template<int <anonymous> > int
g(void*)
 template <int> int g(void *p) { return 0; }
                    ^
/tmp/reduced.cc:4:20: note:                 template<int <anonymous> > int
n::g(void*)
 template <int> int g(void *);</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>