auto with array of strings (BUG?)

Jarrett Billingsley jarrett.billingsley at gmail.com
Wed Aug 19 19:02:28 PDT 2009


On Wed, Aug 19, 2009 at 7:20 PM, Justin<mrjnewt at gmail.com> wrote:
> 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.

Weird.



More information about the Digitalmars-d mailing list