cannot resize a dynamic array of int[int]
Steven Schveighoffer
schveiguy at yahoo.com
Tue Oct 21 12:41:18 PDT 2008
"Jarrett Billingsley" wrote
> On Tue, Oct 21, 2008 at 1:31 PM, Denis Koroskin <2korden at gmail.com> wrote:
>> On Tue, 21 Oct 2008 21:24:28 +0400, Ran <saotome.ran at googlemail.com>
>> wrote:
>>
>>> It should be a stupid question. But I still hope for any response. Could
>>> anyone tell me pls why the following code doesn't work ?
>>>
>>> uint numberOfSubsets(uint n) {
>>> return (1 << n) - 1;
>>> }
>>>
>>> void main(char[][] args) {
>>> int[int] a[];
>>> a.length = numberOfSubsets(3);
>>> }
>>> The generated program runs endlessly. I'm using D2.
>>> Ran
>>
>> This is a bug, try wrapping the assoc. array in a struct so that you make
>> array of structs instead of array of maps. It should help.
>>
>
> It's a bug that's been around for way too fucking long, excuse the
> language. It's apparently a one-character change in the typeinfo for
> AAs.
FYI, this was just posted to the bug report:
> http://d.puremagic.com/issues/show_bug.cgi?id=929
>
>
>
>
>
> ------- Comment #15 from kamm-removethis at incasoftware.de 2008-10-21
> 12:40 -------
> Just to make the patch more explicit: Adding
>
> int TypeAArray::isZeroInit()
> {
> return 1;
> }
>
> to mtype.c and the matching prototype to mtype.h fixes it. Tested in LDC.
-Steve
More information about the Digitalmars-d
mailing list