[Issue 16589] New: Taking address of stack variables in @safe code is allowed in some cases

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Oct 4 03:05:54 PDT 2016


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 at puremagic.com
          Reporter: bugzilla at 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;
}

--


More information about the Digitalmars-d-bugs mailing list