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

            Bug ID: 18740
           Summary: Unhelpful error message when attempting to deduce an
                    initializer list in a template context
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

I have the following code:

-----

#include <vector>

#define RETURNS(...) -> decltype((__VA_ARGS__)) { return (__VA_ARGS__); }

template <typename This, typename... Args>
auto fun(This &&this_, Args&&... args)
RETURNS(this_.fun(std::forward<Args>(args)...))

struct X
{
    void fun(std::vector<int> v) {}
};

int main()
{
    X x;
    fun(x, {1, 2, 3});
}

-----

When compiling, this yields the following errors:

-----

subst.cpp:16:5: error: no matching function for call to 'fun'
    fun(x, {1, 2, 3});
    ^~~
subst.cpp:6:6: note: candidate template ignored: substitution failure [with
This
      = X &, Args = <>]: too few arguments to function call, single argument
'v'
      was not specified
auto fun(This &&this_, Args&&... args)
RETURNS(this_.fun(std::forward<Args>(args)...))
     ^                                                                         
    ~
1 error generated.

-----

As I understand (from the discussion in
http://stackoverflow.com/questions/21573808/using-initializer-lists-with-variadic-templates),
the initializer list could not be deduced.  This is not clear in the message,
however, especially with the (IMO) misleading "Args = <>".

Note: reversing the order of declaration of fun<> and struct X instead yields
the following equally misleading error message (because yes it was, right
there!)

-----

subst.cpp:17:5: error: no matching function for call to 'fun'
    fun(x, {1, 2, 3});
    ^~~
subst.cpp:12:6: note: candidate template ignored: substitution failure [with
      This = X &, Args = <>]: too few arguments to function call, single
      argument 'v' was not specified
auto fun(This &&this_, Args&&... args)
RETURNS(this_.fun(std::forward<Args>(args)...))
     ^                                                                         
    ~
1 error generated.

-----

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to