February 09, 2022

On Wednesday, 9 February 2022 at 12:24:32 UTC, Martin Tschierschke wrote:

>

Thank you I tried it, at the https://tour.dlang.org/ rdmd Playground and
got a casting error, so I changed string to char[8] and it worked:
no return needed: (?)

it's still dead stack data

February 09, 2022

On Wednesday, 9 February 2022 at 12:47:34 UTC, bauss wrote:
[...]

>

So when we do:

string toString() return
{
  return cast(string)bits;
}

There's no error.

Probably a terrible example and I'm not sure if casting like that is even considered safe or should even be done like that, but yeah...

👍👍👍, and thanks.

February 09, 2022

On Tuesday, 8 February 2022 at 18:28:21 UTC, H. S. Teoh wrote:

>

On Tue, Feb 08, 2022 at 06:19:55PM +0000, Salih Dincer via Digitalmars-d wrote:

>

Hope, D will go on to the next version,
the compiler will release up to v10!

Many happy returns of the (D)ay...🥳

  enum Dlang99 = 4026728633831507;

  union Magic
  {
    long data;
    char[8] bits;

    string toString()

In latest dmd git HEAD, you need to annotate this function with return, because it escapes a reference to this. :-)

>
{
  return bits;
}

}
auto magic = Magic(Dlang99<<10|'D');
magic.writefln!"..::%s::..";

T

Okay, you're right. Now worked it: https://run.dlang.io/is/ja1n6C

        auto toString()
        {
            return cast(string)bits;
        }
1 2
Next ›   Last »