Time to start compiling with -dip25

Daniel N no at public.email
Sat Dec 29 11:16:01 UTC 2018


On Saturday, 29 December 2018 at 08:32:21 UTC, Walter Bright 
wrote:
> On 12/28/2018 11:19 PM, Tony wrote:
>> https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md
>
> Also:
>
> https://dlang.org/spec/function.html#return-ref-parameters

Awesome news!

One question, classes, in particular when combined with 
typesafe_variadic_functions seems to break safe, unless DIP25 
style return annotation is added.

"An implementation may construct the object or array instance on 
the stack. Therefore, it is an error to refer to that instance 
after the variadic function has returned"
https://dlang.org/spec/function.html#typesafe_variadic_functions

Is this something which should be addressed by DIP25 or it is out 
of scope?

void main()
{
   auto x1 = fun(1);
   auto x2 = fun(2);

   import std.stdio;
   writeln(x1.a, x2.a);
}

@safe:

class C
{
public:
   int a;
   this(int a) { this.a = a; }
}

C fun(/* return */ C c...)
{
     return c;
}



More information about the Digitalmars-d mailing list