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]

Re: string is const char [] ?


 

 
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.







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