Initializer lists not compiling with template constructors

Products: Intel® C++ Composer XE

Versions: 2013 SP1 (compiler 14.0)

Operating Systems: Windows*, Linux*, OS X*

Software Defect ID: DPD200248554

Problem: The compiler currently gives an error on initializer lists passed to template constructors. For example:

$ cat kb-sample.cpp
#include <initializer_list>
template <class T> class widget {
   template <class U> widget(std::initializer_list<U>);
widget<int> w = { 1, 2, 3};
$ icc -std=c++11 -c kb-sample.cpp
kb-sample.cpp(7): error: no instance of constructor "widget<T>::widget [with T=int]" matches the argument list
            argument types are: (int, int, int)
  widget<int> w = { 1, 2, 3};
compilation aborted for kb-sample.cpp (code 2)
Resolution: This is resolved in Intel C++ Composer XE 2013 SP1 update 2 (compiler 14.0.2). If the arguments to the initializer list are not POD types, you may be able to workaround the problem by explicitly calling the constructor like so:
widget<other_widget> w = { other_widget{a}, other_widget{b}, other_widget{c} };
Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.