www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18088] New: wrong lifetime evaluation of pointers or

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

          Issue ID: 18088
           Summary: wrong lifetime evaluation of pointers or this-pointers
                    in a struct with  safe
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mephisto nordhoff-online.de

file: app.d
~~~~~~~~~~~~~~~~~~~~~

void main() {
    A a = A( true);
}

 safe

struct A {
    bool *lala;

    this( bool i) {
        lala = &aVar;
    }

    bool aVar = true;
}

~~~~~~~~~~~~~~~~~~~~~


$ dmd --version
DMD64 D Compiler v2.077.1
...
$
$ dmd app.d 
app.d(13): Error: address of variable this assigned to this with longer
lifetime
$


I would say the lifetime of "this" is equal to the lifetime of "this", but not
longer

--
Dec 16 2017