The following code produces an error only with gcc:
could not convert '{{"John", 32}, {"Theo", 23}, {"Aun", 43}, {"Vivien", 67}}' from '<brace-enclosed initializer list>' to 'std::vector<Person>'
{"Vivien", 67}};
#include <vector>
struct Person{
//const char* name; // <-- Compiles in both gcc and clang
char name[32]; // <-- Error in gcc only
int age;
};
int main(){
std::vector<Person> parr1 = {{"John", 32},
{"Theo", 23},
{"Aun", 43},
{"Vivien", 67}};
return 0;
}
(https://godbolt.org/z/1qEaaqcac)
What is the reason for this? Is there a way to get the char array version to compile with gcc?
I'm testing with gcc 8.3 and latest clang.