This is the mail archive of the gcc-bugs@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: Problem with string initializer


Andreas Schwab <schwab@suse.de> said:
> The following input to the C++ compiler will result in an error:
> 
> $ cat string.cc
> char x[] = {"asdf"};
> $ g++ -v string.cc

[...]

> string.cc:1: initializer-string for array of chars is too long
> 
> The error does not occur if the braces are omitted.

Hummm... it should probably complain that you are trying to initialize a
char (x[0]) with a const char * ("asdf"). If there are no braces, there is
no error.
--
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

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