https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65094
Bug ID: 65094
Summary: An initializer_list cannot be copied with brace syntax
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ville.voutilainen at gmail dot com
#include <initializer_list>
template <class T> void copy_it(T t)
{
T t2{t}; // #1
}
int main()
{
std::initializer_list<int> x{1,2,3};
std::initializer_list<int> y{x}; // #2
copy_it(x);
}
Both the direct-initialization of a copy in the template (#1) and in the
non-template code (#2) are ill-formed according to gcc. Clang accepts both.
gcc accepts the code if parens are used instead of braces.