[Issue 15847] It is not an error to call opAssign on an uninitialized object

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Mar 30 04:02:33 PDT 2016


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

--- Comment #4 from Marc Schütz <schuetzm at gmx.net> ---
It simply isn't possible to detect that the variable is void-initialized in the
general case. Other languages can do that by way of their design (e.g. Rust,
which does extensive data flow analysis, or languages that have a notion of
typestate), but D can't do that. At best, the compiler could try to detect
trivial cases like in your example. But note that void-initialization is
already @system (at least if references are involved), so as ag0aep6g says, the
user is responsible for using it correctly.

--


More information about the Digitalmars-d-bugs mailing list