This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
string literals in struct initializers with C++
- From: jtc at acorntoolworks dot com (J.T. Conklin)
- To: gcc at gcc dot gnu dot org
- Date: 15 Oct 2002 10:58:05 -0700
- Subject: string literals in struct initializers with C++
- Reply-to: jtc at acorntoolworks dot com
In the process of moving from the gcc-3_2-branch to the CVS head, I found
code with string literals in struct initializers no longer compiles using
g++. I'm not sure whether this is just a tightening of the parser or a
bug.
The following code:
struct foo {
char x[20];
int y;
int z;
};
struct foo foos[] = {
{ "foo", 0, 2 },
{ "bar", 1, 3 }
};
Now results in:
foo.cc:10: error: invalid conversion from `const char*' to `char'
foo.cc:10: error: invalid conversion from `const char*' to `char'
When it used to compile with older versions of g++. It continues to
compile with gcc.
--jtc
--
J.T. Conklin