https://issues.dlang.org/show_bug.cgi?id=17448

Andrei Alexandrescu <and...@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |and...@erdani.com

--- Comment #8 from Andrei Alexandrescu <and...@erdani.com> ---
The problem here is the delegate escapes a pointer to a struct. The compiler is
free to move around structs that are manipulated by value, therefore escaping
&this from any struct method is not safe. (Technically the type of `this`
inside a method of struct T is `scope ref T`, not `ref T`.)

Sadly the way to go from here is disallow the code entirely in @safe mode. The
notion that the compiler can freely move around value types is deeply embedded
in the language, and has many benefits. There are no plans to change that.

For data that doesn't change location in memory, dynamic or user-defined
allocation is the go-to solution.

--

Reply via email to