Choosing an Approach for the Template Lowering of _d_arrayctor
Teodor Dutu
teodor.dutu at gmail.com
Thu Nov 25 18:50:28 UTC 2021
On Thursday, 25 November 2021 at 16:16:11 UTC, Stanislav Blinov
wrote:
> What can be done then? If I understand correctly, the union
> approach was arrived at due to void initialization, as in case
> of exception array of garbage data is getting destructed. But
> then, couldn't one just write a T.init into the whole array if
> an exception is thrown, and not rely on a union at all?..
Actually, I used void initialisation because `T.init` couldn't be
used when T is a nested struct, because of the context pointer,
which is unavailable in the scope of `_d_arrayctor`.
On Thursday, 25 November 2021 at 16:16:11 UTC, Stanislav Blinov
wrote:
>
>>```
>> foreach (ref it; result)
>> emplaceInitializer(it); // this is nothrow
>>```
> ...pff, yeah, of course, and then we run into a segfault if
> it's an array of nested
> structs, which was the problem "solved" with void
> initialization in the first place.
> Not fun >:-E
I think you've already touched on what I said above, here. It's
just that there wouldn't be a seg fault, but a compiler error,
because of the aforementioned context pointer.
More information about the Digitalmars-d
mailing list