Transferring 32 bits
Adam D Ruppe
destructionator at gmail.com
Thu Aug 25 12:42:46 UTC 2022
On Thursday, 25 August 2022 at 12:22:56 UTC, Salih Dincer wrote:
> scope res = new S(bytes);
The `scope` keyword means you promise not to let any references
escape this scope. Your toString does do that, so the compiler
might optimize this `new` away; the scope and new keywords here
cancel each other out, leaving you with the same problem.
> It's ok when I construct S with the new operator!
Still wrong code, but it'd work here because the bytes then are
GC managed instead of stack temporaries so you still cast to
immutable but at least it isn't use-after-free.
More information about the Digitalmars-d
mailing list