auto with array of strings (BUG?)

Justin mrjnewt at gmail.com
Wed Aug 19 16:20:53 PDT 2009


Jarrett Billingsley Wrote:
> There's two annoying things going on here:
> 
> 1) The type of string literals is not char[], it's char[n] where n is
> the length of the string.  I don't know why this is.
> 2) With array literals, the compiler simply determines the type of the
> array as being a dynamic array of the type of the first element,
> rather than making it an array of the common type of all the elements.
> 
> That being said I have no idea why the compiler is allowing "cruelly",
> which is of type char[7], to be implicitly converted to char[5].  I
> thought that was not legit.

Adding const to the auto declaration will cause an error at compile time.



More information about the Digitalmars-d mailing list