www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16589] New: Taking address of stack variables in safe code

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

          Issue ID: 16589
           Summary: Taking address of stack variables in  safe code is
                    allowed in some cases
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Each of the return statements should all generate an error:

struct S
{
    int data;

     safe int* access1()
    {
        return &data;
    }

     safe S* access2()
    {
        return &this;
    }
}

 safe int* access3(ref S s)
{
    return &s.data;
}

 safe S* access4(ref S s)
{
    return &s;
}

 safe int* access5(S s)
{
    return &s.data;
}

 safe S* access6(S s)
{
    return &s;
}

--
Oct 04 2016