www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22298] New: [DIP1000] Nested function's scope parameters can


          Issue ID: 22298
           Summary: [DIP1000] Nested function's scope parameters can be
                    assigned to variables in enclosing function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: giacomo.ratto protonmail.com

This makes possible to get a pointer to a local variable within an expired
stack frame:
void g(scope void delegate(scope int*)  safe cb)  safe {
        int x = 42;

void main()  safe {
        int* p;
        void f(scope int* i)  safe {
                p = i;

        // address of x has escaped g
        assert(*p == 42);

Sep 10 2021