www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17370] New: [DIP1000] Escaping scope pointers possible via


          Issue ID: 17370
           Summary: [DIP1000] Escaping scope pointers possible via struct
                    GC allocation
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mathias.lang sociomantic.com

The following compiles and runs with 2.074.0 and v2.075.0-devel-5cfc8d982
(latest master):

void main ()  safe
    int* ptr = fwd();
    assert(ptr !is null);

int* fwd ()  safe
    int i;
    return new Struct(&i).oops; // Leaving out `new` correctly detects escaping

struct Struct
    int* oops;

May 05 2017