Bug 19389 – Multiple assignment does not work for struct members

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2018-11-10T10:50:54Z
Last change time
2018-12-12T13:46:32Z
Assigned to
No Owner
Creator
KytoDragon

Comments

Comment #0 by kytodragon — 2018-11-10T10:50:54Z
struct Foo { int x; this(int dummy) { x = dummy; } } struct Bar { Foo a; Foo b; this(int dummy) { a = (b = Foo(dummy)); } } void main() { Foo a; Foo b; a = (b = Foo(7)); assert(b.x == 7 && a.x == 7); // works Bar bar = Bar(7); assert(bar.b.x == 7 && bar.a.x == 7); // !!! fails, bar.b.x is 0 !!! } This was discovered in LDC 1.12.0 and confirmed broken in DMD 2.082.0 . According to run.dlang.io, this has worked from v2.060 to 2.069, and fails since 2.070.
Comment #1 by bugzilla — 2018-12-11T08:21:25Z
Comment #2 by github-bugzilla — 2018-12-12T13:46:31Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/62500a6162958efa6d3ecb518abda3ae2f5faef6 fix Issue 19389 - Multiple assignment does not work for struct members https://github.com/dlang/dmd/commit/9f849a4a470c4c5c0fba4af3739aca6250615e56 Merge pull request #9066 from WalterBright/fix19389 fix Issue 19389 - Multiple assignment does not work for struct members merged-on-behalf-of: Razvan Nitu <[email protected]>