[Issue 15869] RVO can overwrite argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 22 05:36:55 UTC 2018


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

--- Comment #11 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
ahem. i was under impression that "constructors" in D are actually
"post-initializers". i.e. that object must be fully initialized with default
values before calling ctor, and can't have "unconstructed" anything (unless it
has `=void` as default value, of course). that is, in the given case, compiler
should detect that `a` is actually used, and fully initialize it before calling
ctor of `XX`. or generate error on *any* "use-before-init" access, including
things like "v++" and such.

that is, it looks to me that "pragmatic solution" is not really solving
anything in this case: it just hacks around one very specific case, and in the
same time makes D behavior even more unintuitive.

--


More information about the Digitalmars-d-bugs mailing list