www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17977] New: [scope] escaping reference to a temporary struct


          Issue ID: 17977
           Summary: [scope] escaping reference to a temporary struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

The following code:

  struct List {
    Elem front()  safe return scope;
    ~this()  trusted scope;
     disable this(this);
    void* data;

  struct Elem {
    void* data;

  void test()  safe {
    Elem elem;
        // error: elem gets a pointer that has a lifetime limited to List()
        elem = List().front;

Nov 10 2017