[Issue 18281] New: Compiler rejects safe code in @safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 23 01:33:23 UTC 2018


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 at puremagic.com
          Reporter: slavo5150 at 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.

--


More information about the Digitalmars-d-bugs mailing list