Bug 6186

Benjamin Thaut code at benjamin-thaut.de
Wed Oct 2 11:58:45 PDT 2013


Am 02.10.2013 20:43, schrieb Kenji Hara:
> If the given argument to the out parameter is not correctly initialized
> (eg. void initialized variable), calling dtor for the argument is
> absolutely unsafe. That's the reason why my patch was rejected by Walter.
>
> Alternative language semantics in my thought is:
> ---
> If an out parameter typed T exists, and
>    1. T has elaborate destructor
>    2. T.init represents logically invalid object (T is nested struct,
> and/or T has @disable this();)
> Automatic blit initializing for the out parameter would be unsafe.
>
> So semantic analysis would reject such a out parameter declaration.
> ---
>
> But I'm still not sure the rule is enough useful for many cases...
>
> Kenji Hara
>

I would also be fine with a out paramter always getting rejected as soon 
as T has a destructor. For such cases a easy fix would be to just 
replace out with ref. I actually grep-ed my whole codebase and replaced 
all "out" with "ref" because of this bug.


More information about the Digitalmars-d mailing list