memory safety checks and trust
Walter Bright
newshound2 at digitalmars.com
Wed Apr 15 06:12:22 UTC 2020
On 4/14/2020 1:40 PM, Steven Schveighoffer wrote:
> Also, this compiles just fine, and gives you the stack pointer value:
>
> size_t stackPtr() @system
> {
> int i;
> return cast(size_t)&i;
> }
Yup. I also gave workarounds to Adam's example.
> I can do this too, apparently since it's a TLS array and not a heap array, totes
> ok!
>
> int*[1] arr;
>
> void bar()
> {
> int i;
> arr[0] = &i;
> }
Ironically, I argue for consistency with "safe by default" and you argue for
special cases, and here the reverse.
But be careful, you may talk me into disallowing these cases, too :-/
More information about the Digitalmars-d
mailing list