www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17470] New: [scope] this has longer lifetime then this

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

          Issue ID: 17470
           Summary: [scope] this has longer lifetime then this
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: uplink.coder googlemail.com

The following code:

 safe struct X {
 byte[] s;
 byte[9] a;
 this(int n)
 {
   assert(n < 9);
   s = a[0 .. n];
 }
}

raises the error

t.d(8): Error: address of variable this assigned to this with longer lifetime
While infact, this has the exact same lifetime as this (it's the same pointer)

--
Jun 05