[Issue 20581] DIP1000 wrongly flags hidden ref temporary

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 4 12:28:11 UTC 2020


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

kinke <kinke at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net

--- Comment #3 from kinke <kinke at gmx.net> ---
This seems to be a 2.091 regression. Using an explicit non-temporary still
works, with an equivalent lifetime of the temporary:

void main() @safe
{
    int[5] a = [ 1, 2, 3, 4, 5 ];
    {
        auto blub = retro(a[]).source;
        assert(blub is a[]);
    }
}

The original expression with temporary is lowered to:

assert(((int[] __assertOp4 = retro(a[]).source;) , __assertOp4) is a[],
_d_assert_fail(__assertOp4, a[]));

// Generates the message for -checkaction=context and takes both
// operands by `auto ref const`.
string _d_assert_fail(ref const(int[]) a, const(int[]) b) { ... }

_d_assert_msg might throw later, using the generated msg, as Florian mentioned.

--


More information about the Digitalmars-d-bugs mailing list