From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23292 invoked by alias); 15 Oct 2002 19:02:48 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 23285 invoked from network); 15 Oct 2002 19:02:47 -0000 Received: from unknown (HELO orac.acorntoolworks.com) (66.123.74.10) by sources.redhat.com with SMTP; 15 Oct 2002 19:02:47 -0000 Received: (from jtc@localhost) by orac.acorntoolworks.com (8.11.6/8.11.6) id g9FJ2kT08595; Tue, 15 Oct 2002 12:02:46 -0700 (PDT) To: gcc@gcc.gnu.org Subject: Re: string literals in struct initializers with C++ References: <87vg43bn4i.fsf@orac.acorntoolworks.com> Reply-To: jtc@acorntoolworks.com From: jtc@acorntoolworks.com (J.T. Conklin) Date: Tue, 15 Oct 2002 13:10:00 -0000 In-Reply-To: <87vg43bn4i.fsf@orac.acorntoolworks.com> Message-ID: <87fzv7bk4p.fsf@orac.acorntoolworks.com> User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-10/txt/msg00855.txt.bz2 jtc@acorntoolworks.com (J.T. Conklin) writes: > 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. FWIW, The same or similar problem appears to effect the following code: #include struct bar { std::string s; int y; int z; }; bar bar_array[] = { { "abc", 1, 2 }, { "def", 2, 4 }, { "ghi", 3, 6 }, { "klm", 4, 8 } }; Which results in: bar.cc:14: error: conversion from `const char[4]' to non-scalar type `bar' requested bar.cc:14: error: conversion from `const char[4]' to non-scalar type `bar' requested bar.cc:14: error: conversion from `const char[4]' to non-scalar type `bar' requested bar.cc:14: error: conversion from `const char[4]' to non-scalar type `bar' requested Unlike the privious example, this one can't be worked around with an extra layer of {}'s. And since I neglected to mention it before, this is a g++ from the CVS head, on QNX 6.2 (the changes I submitted for QNX in August with slight tweaks as suggested by Zack and as necessary to to adapt to the CVS head. --jtc -- J.T. Conklin