[Issue 15869] RVO can overwrite argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 14 09:29:53 UTC 2018


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

--- Comment #7 from Yuxuan Shui <yshuiv7 at gmail.com> ---
> As a result, &a is technically use-before-initialization and invalid.

If that's the case, this shouldn't compile:

struct Set {
    @disable this(this);
    int value = 0;
}
@safe Set clobber(Set* a) {}
struct XX {
    Set a = Set(1);
    @safe this(int n) {
        a = clobber(&a); // use-before-init
    }
}

But it does.

--


More information about the Digitalmars-d-bugs mailing list