On 12/06/2016 06:10 PM, Basile B. wrote:
> On Wednesday, 7 December 2016 at 00:20:11 UTC, Ali Çehreli wrote:
>> tl;dr; go to the TLDR section below. :)
>>
>> [...]
>>
>> struct S {
>>     int i = void;
>>     double d = void;
>>     ubyte[10_000] a = void;
>> }
>>
>> class C {
>>     S s = void; // (Same result even without the =void)
>> }
>>
>> void main() {
>> }
>>
>> [...]
>> 0000000004446260 0000000000003633 T
>> _D4core4time8Duration13_toStringImplMxFNaNbNfZAya
>> 0000000004505140 0000000000003707 T _d_arraysetlengthiT
>> 0000000006681456 0000000000010032 V _D6deneme1C6__initZ
>>
>> Now we have a 10032 byte C.init.
>>
>> Is there a rationale for this or is this an implementation quality
>> issue? Is there a bug already? I could not find one.
>>
>> Also, I failed to find the "= void" documentation e.g. not on the
>> struct spec page.
>>
>> Thank you,
>> Ali
>
> Non initialized classes just don't work. Because of the hidden classes
> fields an initializer is **always** needed. What happens in your example
> is that the initializer size is sub optimal.

Understood. Please confirm whether the following is a bug. Just because a class uses a *pointer* to a void-initialized struct, the struct gets a .init:

struct MyStruct(T) {
    T[10_000] a = void;
}

// Same with struct
class Outer {
    MyStruct!ubyte* s;
}

void main() {
}

0000000006681728 0000000000010000 V _D6deneme15__T8MyStructThZ8MyStruct6__initZ

Make the struct a non-template and MyStruct.init disappears as expected.

Ali

Reply via email to