In C++ learning website (https://www.learncpp.com/cpp-tutorial/6-9a-dynamically-allocating-arrays/) there is a claim that GCC has a bug related to C-style string initialization when new operator is involved:
As of the time of writing, the GCC still has a bug where initializing a dynamically allocated array of chars using a C-style string literal causes a compiler error:
char *array = new char[14] { "Hello, world!" }; // doesn't work in GCC, though it should
I am using GCC version 7.4.0.
If I try to compile this excerpt I get:
error: invalid conversion from ‘const char*’ to ‘char’ [-fpermissive]
char *array = new char[14] { "Hello, world!" };
If I try to compile code like this:
char *array = new char[14] {'H', 'e', 'l', 'l', 'o', 0}
then it works as expected.
I am assuming this is considered a bug since:
char array[14]{ "Hello, world!" };
works as expected.
I could not find more information on this. Can anybody confirm or deny that this is a GCC bug?