This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: string is const char [] ?
- To: Richard Henderson <rth at cygnus dot com>
- Subject: Re: string is const char [] ?
- From: Kaz Kylheku <kaz at espresso dot cafe dot net>
- Date: Thu, 25 Jun 1998 01:09:37 -0700 (PDT)
- cc: Kamil Iskra <kamil at dwd dot interkom dot pl>, egcs at cygnus dot com, egcs-bugs at cygnus dot com
On Wed, 24 Jun 1998, Richard Henderson wrote:
> On Wed, Jun 24, 1998 at 03:07:30PM +0200, Kamil Iskra wrote:
> > Don't get me wrong, I'm sure you know the standard far better than I do,
> > but are you SURE that it disallows this initialisation syntax?
>
> For non-constant static or file-scope variables, the "" form is
> legal. For automatic variables, it is not.
>
> > I find it
> > hard to believe, since first, I think this syntax is very common (at least
> > I use it quite often), and second, this syntax is fine in C,
>
> Well, gcc provides the "" form for automatic variables as an extension.
> I wish it did not, for I often find folks initializing things at runtime
> taking up hordes of .text space, when they weren't intending to.
To clarify, you mean that:
{
char x[] = "abcd";
}
is wrong? That is perfectly valid C. But it does potentially take up
.text space, since the compiler will likely store the "abcd" string
literal there and generate a copy operation.