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.  The only
> backward-compatibility provided in the standard is [conv.array]/2,
> that allows string literals to be converted to non-const `char*'.
> Hence, string literals cannot be used to initialize a char[].  At
> least a warning should be issued in this case.

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'};

??? IMO, this is INSANE.

/ Kamil Iskra    AmigaOS  Linux/i386  Linux/m68k               \
| GeekGadgets GCC maintainer   UNIX system administrator       |
| iskra@student.uci.agh.edu.pl  kiskra@ernie.icslab.agh.edu.pl |
\ kamil@dwd.interkom.pl   http://student.uci.agh.edu.pl/~iskra /



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