g++: sorry, unimplemented: non-trivial designated initializers not supported

g++ (version g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)) report:

$ g++ -std=c++11 solution.cpp -o sol

solution.cpp: In function ‘int main()’:
solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported
     Stat init_stat {.depth = 0, .moves = tv, .vec = init};
                                                         ^
solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported
solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported
make: *** [all] Error 1

For one program. The program is like this:

First, declare a struct

struct Stat {
    vector<int> vec;
    int depth;
    vector<pair<int, int>> moves;
};

Later part, define a Stat struct object with:

Stat init_stat {.depth = 0, .moves = tv, .vec = init};

Here, tv and init are variables defined earlier.

The compiler reports the above error.

To make is work with g++ 4.8.1:

Define a Stat struct object as:

Stat init_stat { .vec = init, .depth = 0, .moves = tv};

Here, the order of elements are exactly the same as the order of the elements in the declaration.

Answered by anonymous.

Leave a Reply

Your email address will not be published. Required fields are marked *