www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18283] New: -dip1000 doesn't catch invalid local reference

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

          Issue ID: 18283
           Summary: -dip1000 doesn't catch invalid local reference
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: slavo5150 yahoo.com

import std.stdio;

void main()  safe
{
    string foo = "foo";
    string* ls0;
    string* p1, p2;

    ls0 = &foo;
    p1 = ls0;
    ls0.destroy();
    p2 = ls0;
    writeln(p2.length);
}

Compile with `-dip1000`

Error: program killed by signal 11

https://run.dlang.io/is/6L6zcH


========================================
Compiling the same example without `-dip1000`, I get:

onlineapp.d(9): Error: cannot take address of local foo in  safe function main

https://run.dlang.io/is/rHpuf1


Though this could be an issue with `destroy()`.  Not sure.

--
Jan 22