Bug 18708 – Flow analysis in constructors not done correctly for if, ||, &&

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-04-02T21:24:28Z
Last change time
2018-04-04T22:26:34Z
Keywords
accepts-invalid, rejects-valid
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=9665

Comments

Comment #0 by bugzilla — 2018-04-02T21:24:28Z
struct S { int y; @disable this(); } // so construction is required class C { S s; this(S t) { if (bar(s = t)) foo(); // bug: Error: one path skips field s } this(S t, int i) { i || bar(s = t); // bug: should give error } this(S t, int i, int j) { i && bar(s = t); // bug: should give error } this(S t, int i, long j) { i ? bar(s = t) : i; // good: Error: one path skips field s } this(S t, int i, long j) { i ? i : bar(s = t); // good: Error: one path skips field s } } int bar(S s); int foo();
Comment #1 by bugzilla — 2018-04-03T01:26:39Z
Comment #2 by github-bugzilla — 2018-04-04T22:26:32Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/6cc2cd762eb8d147925a928d463cf76aa510e623 fix Issue 18708 - Flow analysis in constructors not done correctly for if, ||, && https://github.com/dlang/dmd/commit/190e2e083df1c56ba6b19091a89da03f1e8fffc8 Merge pull request #8118 from WalterBright/fix18708 fix Issue 18708 - Flow analysis in constructors not done correctly fo…