Bug 19030 – CTorFlow checking is too aggressive and only checks whether a this call is present

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-27T09:17:31Z
Last change time
2018-07-03T09:27:23Z
Assigned to
No Owner
Creator
Seb
See also
https://issues.dlang.org/show_bug.cgi?id=18719

Comments

Comment #0 by greensunny12 — 2018-06-27T09:17:31Z
https://issues.dlang.org/show_bug.cgi?id=18719 introduced a regression as it only checks whether a this() call is present, but not what the this call actually does. For example, this slightly modified example from 18719 no produces an error even though it sets x only once: --- struct S { int x = -1; this(int y) immutable { x = y; import std.stdio; writeln("Ctor called with ", y); } void opAssign(int) immutable; } class C { S x; this() immutable { this(42); /* Initializes x. */ x = 13; /* Breaking immutable, or ok? */ } this(int x) immutable { } } ---
Comment #1 by razvan.nitu1305 — 2018-07-02T10:13:45Z
Actually, this is not a bug, it's the intended behavior. It is specified in the spec that after a delegate constructor call all fields are considered constructed: https://github.com/dlang/dlang.org/blob/master/spec/struct.dd#L497 .