This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

string literals in struct initializers with C++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]