www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18281] New: Compiler rejects safe code in safe

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

          Issue ID: 18281
           Summary: Compiler rejects safe code in  safe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: slavo5150 yahoo.com

void main()  safe
{
    string foo = "foo";
    string*[] ls;
    ls ~= &foo;
}

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

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

There is no escaping reference, so I don't see why the compiler is rejecting
this code.

--
Jan 22 2018