[LLVMbugs] [Bug 15273] New: Diagnostics for Ambiguous Functions could be improved

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Feb 15 01:26:36 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=15273

            Bug ID: 15273
           Summary: Diagnostics for Ambiguous Functions could be improved
           Product: clang
           Version: 3.2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: couchdeveloper at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

-- 
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/20130215/3640659c/attachment.html>


More information about the llvm-bugs mailing list