Assigning to char[N]

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 6 10:39:54 PST 2012


On Thu, 02 Feb 2012 00:38:26 -0500, Ali Çehreli <acehreli at yahoo.com> wrote:

> On 02/01/2012 04:24 PM, Andrej Mitrovic wrote:
>  > OT: Just saw fill() by accident and something caught my eye:
>  >
>  > char[100] a;
>  > fill(a[], "bla");  // fail, ok
>  >
>  > int[100] a;
>  > fill(a[], "bla");  // works
>  >
>  > It could be a constraint issue.
>
> Although "bla" is an array of char, it is a range of dchar; and dchar  
> automatically converts to int.

But this is the kind of unintuitive shit that treating char arrays not as  
arrays in *some* parts of D causes great confusion and silly limitations.   
The above should be the opposite, the first line should pass and the  
second should fail.

>
>  > To bugzilla?
>
> I don't think so, because it's just dchar to int conversion.

You are likely to get an "invalid" response due to the strict views of  
Andrei, but I think it's unacceptable behavior for fill to say it cannot  
fill a string with string data.

-Steve


More information about the Digitalmars-d-learn mailing list