[Issue 13848] overlapping initialization for r

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Dec 10 07:41:12 PST 2014


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

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to deadalnix from comment #0)
> 	auto fun() {
> 		return SS(a, p);
> 	}

Your're trying to initialize SS.a by the value a. and SS.r by using p. Of
course SS.a and SS.r are overlapped each other, so initializing the two fields
at the same time is invalid.

In this case, you cannot use literal style syntax to construct SS. An
alternative way is:

auto fun() {
    SS ss = {a:a, p:p};  // use StructInitializer syntax
    return ss;
}

--


More information about the Digitalmars-d-bugs mailing list