This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: string is const char [] ?
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: string is const char [] ?
- From: Horst von Brand <vonbrand at inf dot utfsm dot cl>
- Date: Wed, 24 Jun 1998 11:02:29 -0400
- cc: Kamil Iskra <kamil at dwd dot interkom dot pl>, egcs at cygnus dot com, egcs-bugs at cygnus dot com
Alexandre Oliva <oliva@dcc.unicamp.br> said:
> Kamil Iskra <kamil@dwd.interkom.pl> writes:
> > On 23 Jun 1998, Alexandre Oliva wrote:
> >> > char a1[] = "test not const";
> >> This line should cause egcs to flag an error.
I think this is ridiculous. Why should it matter that the value from which
a particular variable is _initialized_ is or not a constant? With this
reasoning, we'd have:
int i = 5; // illegal?!
int j = k; // OK, as long as k isn't 'const int'?!
> > 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'};
By the above reasoning, this should be an error too.
Besides, in C doing what you state above is quite common, is compatibility
with C being thrown out the window just like that for no reason at all?
> How about:
> const char a1[] = "test not const";
That means something totally different.
Something is very broken here. Maybe my understanding of the issue ;)
--
Dr. Horst H. von Brand mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513