This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: string is const char [] ?
- To: oliva at dcc dot unicamp dot br (Alexandre Oliva)
- Subject: Re: string is const char [] ?
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Wed, 24 Jun 98 10:08:45 PDT
- Cc: kamil at dwd dot interkom dot pl, egcs at cygnus dot com, egcs-bugs at cygnus dot com
On 23 Jun 1998, Alexandre Oliva wrote:
> >> > char a1[] = "test not const";
>
> >> This line should cause egcs to flag an error.
Kamil Iskra <kamil@dwd.interkom.pl> writes:
> > Excuse me?! I missed the original mail, but do you really suggest that all
> > the programmers should suddenly switch to:
>
> > char a1[]={'t', 'e', 's', 't', ' ', 'n', 'o', 't', ' ', 'c', 'o', 'n',
> > 's', 't', '\0'};
Alexandre Oliva writes:
> How about:
> const char a1[] = "test not const";
Kamil is trying to initialize a char[], so your suggestion is irrelevant.
Programmers must sometimes initialize a writable string, and the standard
way to do this in C is exactly the way you claim is forbidden. This would
need to be documented as a language incompatibility.
I don't believe that you are correct, Alexandre. I think you are
confusing assignment (where there is a conversion) with initialization.
If the standard is unclear, this is a case where the committee should be
asked to produce a clarification.