Wrong lowering for a[b][c]++

Martin Nowak dawg at dawgfoto.de
Thu Mar 22 10:15:13 PDT 2012


On Thu, 22 Mar 2012 15:35:06 +0100, H. S. Teoh <hsteoh at quickfur.ath.cx>  
wrote:

> On Thu, Mar 22, 2012 at 03:26:00PM +0100, Andrej Mitrovic wrote:
>> On 3/22/12, Jesse Phillips <jessekphillips+D at gmail.com> wrote:
>> > double[int] a;
>> > What is the result of your code on 'a' now? double.init is NAN.
>>
>> Hmm this is interesting. With 2.058:
>>
>> double[int] a;
>> a[0]++;
>> writeln(a[0]);  // prints 1
>>
>> double b;
>> b++;
>> writeln(b);  // prints nan
>
> This is because in aaA.d _aaGetX creates a new entry if one isn't found,
> but because it has no direct access to value types (only has typeinfo),
> it doesn't know what value .init has. It sets the value to binary zero
> by default.
TypeInfos have a ubyte[] array with the needed data.
It's badly named though.

rdmd --eval="writeln(typeid(double).init)"

But the AA doesn't have access to the typeinfo of the value anyhow.


More information about the Digitalmars-d mailing list