string is const char [] ?

Kamil Iskra kamil@dwd.interkom.pl
Wed Jun 24 03:01:00 GMT 1998


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 /




More information about the Gcc mailing list