[LLVMbugs] [Bug 18047] New: Failure to deduce std::initializer_list<T> from {"foo", "bar"} when T is a parameter pack

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Nov 24 12:23:04 PST 2013


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

            Bug ID: 18047
           Summary: Failure to deduce std::initializer_list<T> from
                    {"foo","bar"} when T is a parameter pack
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Casey at Carter.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11600
  --> http://llvm.org/bugs/attachment.cgi?id=11600&action=edit
Test case.

This program is compiled correctly:

#include <initializer_list>

template <typename T>
void function(std::initializer_list<T>) {
}

int main() {
    function({"foo", "bar"});
}

This program fails to compile:

#include <initializer_list>

template <typename... T>
void function(std::initializer_list<T>...) {
}

int main() {
    function({"foo", "bar"});
}

instead reporting a compile error:

main.cpp:8:5: error: no matching function for call to 'function'
    function({"foo", "bar"});
    ^~~~~~~~
main.cpp:4:6: note: candidate function [with T = <char const[4]>] not viable:
no known conversion from 'const char [4]' to 'char const[4]' for 1st argument
void function(std::initializer_list<T>...) {
     ^
1 error generated.

It appears that the compiler is failing to perform the array-to-pointer
conversion step of the deduction per [temp.deduct.call]/2, but only when the
type being deduced is part of a parameter pack.

-- 
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/20131124/e2db7b6e/attachment.html>


More information about the llvm-bugs mailing list