<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 --- - Diagnostics for Ambiguous Functions could be improved"
   href="http://llvm.org/bugs/show_bug.cgi?id=15273">15273</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Diagnostics for Ambiguous Functions could be improved
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>couchdeveloper@gmail.com
          </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>This is a motivating example to improve the diagnostics of clang.

The diagnostic messages for ambiguous function templates could be better. 

For example, the template parameters are not included in the list of candidates
(produced when compiling the small sample (see end of post) with Xcode):


.../main.cpp:45:5: error: call to 'foo' is ambiguous
    nn::A<B,C, void>::foo(i);
    ^~~~~~~~~~~~~~~~~~~~~
.../main.cpp:26:21: note: candidate function
        static void foo(T const& t) {
                    ^
.../main.cpp:28:21: note: candidate function
        static void foo(T&& t) {
                    ^
.../main.cpp:26:21: note: candidate function
        static void foo(T const& t) {
                    ^
.../main.cpp:28:21: note: candidate function
        static void foo(T&& t) {
                    ^
1 error generated.





Expected Results:

The diagnostic messages for ambiguous function templates should be as precise
as necessary in order to identify the reason of the ambiguity. That, for
example, should at least include the template parameters of the ambiguous
functions and should also list any implicit conversions from the argument to
the parameters types.

A verbose diagnostics may include the reason for the equal matched viable
functions. Maybe with same "rank" info?

An extra ordinary cool feature would also include a hint for the most
"unexpected" causes for ambiguity, mainly for non-expert programmers. Since a
user friendly representation of this is possibly very difficult to achieve,
this feature is just a "nice to have".



Sample:

namespace nn {

    template <typename...>
    struct A;

    template <>
    struct A<void> {
        static void foo() {}
    };

    template <typename T, typename... Ts>
    struct A<T, Ts...> : A<Ts...>
    {
        using A<Ts...>::foo;

        static void foo(T const& t) {
        }
        static void foo(T&& t) {
        }
    };

}


int main(int argc, const char * argv[])
{
    struct B {
        B(int) {}
    };
    struct C {
        C(int) {}
    };

    const int i = 0;
    nn::A<B,C, void>::foo(i);

    return 0;
}</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>