[Issue 20084] return by auto ref unsafe - and different code for inout ref and ref.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 25 19:03:42 UTC 2019


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

kinke <kinke at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net
           Hardware|x86                         |All
                 OS|Mac OS X                    |All
           Severity|enhancement                 |normal

--- Comment #1 from kinke <kinke at gmx.net> ---
With `-dip1000`, get() returns a reference, just like inoutGet().

Even this compiles with `-dip1000 -dip25` but clearly reads beyond the stack:
-----
@safe:

struct W(T) {
    T value;
    ref T front() return { return value; }
}

ref get(T)(W!T value) {
    return value.front;
}

void foo() {
    int i = get(W!int(4));
}
-----

--


More information about the Digitalmars-d-bugs mailing list