Community
cancel
Showing results for 
Search instead for 
Did you mean: 
fullyarticulate
Beginner
100 Views

Bug in C++11 initializer_list support

I believe this is a bug. G++ compiles it as I'd expect, and my reading of the C++11 docs would seem to indicate this is a valid construct. I'm using icpc 12.1.0 20110811.

[cpp]#include 
#include 

class CConfig {
public:
        const char *name;
        bool flag;
        std::vector items;

        CConfig(const char *n, bool f, std::initializer_list i) {
                name = n;
                flag = f;
                for (auto itr = i.begin(); itr != i.end(); ++itr)
                        items.push_back(*itr);
        }
};

static CConfig config("first", true, { 1, 2, 3, 4 });
static CConfig config2 = { "first", true, { 1, 2, 3, 4 } };

int
main()
{
        printf("config.name=%s\n", config.name);
}
[/cpp]

Compile with g++ -std=c++0x or icpc -std=c++0x

icpc complains with:
[plain]bug.cc(18): error: expected an expression
  static CConfig config("first", true, { 1, 2, 3, 4 });
                                       ^
bug.cc(19): error: initialization with "{...}" is not allowed for object of type "CConfig"
  static CConfig config2 = { "first", true, { 1, 2, 3, 4 } };
                           ^
compilation aborted for bug.cc (code 2)
[/plain]

Any suggestions for an alternate construct? Confirmation that this is a bug? Or are initializer lists just not supported in ICPC yet?

Thanks!
0 Kudos
3 Replies
Feilong_H_Intel
Employee
100 Views

Hi there,

Thanks for the small test case. I've reproduced the problem and entered it to our problem-tracking database. I'll let you know when I have an update regarding this issue.

Thank you.
--
Feilong H.
Intel Developer Support

Tools Knowledge Base: http://software.intel.com/en-us/articles/tools
Judith_W_Intel
Employee
100 Views


C++0x general and extendedinitalizer lists are not a feature we ever intended to support in version 12.1. So this is not really a bug, it is an intentionally unimplemented feature. We have no plans to backport this feature into 12.1. We are trying to finish theimplementationin our next major release of the compiler.

Sorry for the inconvenience.

Judy
Feilong_H_Intel
Employee
100 Views

This feature has been implemented in 14.0 compiler.  So I'm closing this thread now.

Reply