[Issue 20581] New: DIP1000 wrongly flags hidden ref temporary

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 14 20:44:33 UTC 2020


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

          Issue ID: 20581
           Summary: DIP1000 wrongly flags hidden ref temporary
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: moonlightsentinel at disroot.org

Compiling phobos unittests with -checkaction=context causes DIP1000 to raise an
error about a hidden temporary outliving the referenced content.

Reduced example:

void main() @safe
{
    int[5] a = [ 1, 2, 3, 4, 5 ];
    assert(retro(a[]).source is a[]); // => Hidden temporary __assertOp4
}

auto retro(return scope int[] s) @safe
{
    static struct R
    {
        int[] source;
    }
    return R(s);
}


safe.d(6): Error: address of variable a assigned to __assertOp4 with longer
lifetime

--


More information about the Digitalmars-d-bugs mailing list