Instantiation of nested structs should be allowed outside their parent scope

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Tue Nov 9 18:35:44 UTC 2021


On Tuesday, 9 November 2021 at 15:39:49 UTC, Stanislav Blinov 
wrote:
> On Tuesday, 9 November 2021 at 12:59:08 UTC, Alexandru Ermicioi 
> wrote:
>
>> I'd rather have compiler throw errors rather than having yet 
>> another potential segfault in application which needs to be 
>> checked.
>
> In that case compilation of 99% of D programs on Unix has to 
> fail immediately. Because, potentially, they can all segfault 
> before even reaching _Dmain. Only those that don't in any way 
> link to C runtime may compile freely.
>
> Sound silly enough?

If compiler can help in preventing potential bugs, then it should 
do that, given it is in scope of what it handles. C runtime is 
not handled by it, and therefore it can only make assumptions 
that is working correctly just like any other already compiled 
library that is being used by the source code that is compiled 
right now.

The problem from discussion in this thread seems to be due to 
bugs in how copy constructor is implemented, therefore first 
thing would be best to do, is to file a bug report. After this 
you can try fix it yourself, wait for other person do it, or 
motivate people in doing it.

Imho this is not a minor thing, and should be fixed quite fast. 
In meantime, you could try make inner struct static. This should 
eliminate the context pointer.

Best regards,
Alexandru


More information about the Digitalmars-d mailing list