Bug 9003 – Nested structs smetimes have null context pointers in static struct

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-12T04:59:00Z
Last change time
2012-11-13T13:32:35Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2012-11-12T04:59:31Z
Currently it's allowed to have nested struct fields in static struct (or global templated structs): --- void main() { int i; struct NS { int n; // Comment to pass all asserts // int n2; // Uncomment to fail assert on line 19 int f() { return i; } } static struct SS1 { NS ns; } SS1 ss1; assert(ss1.ns != NS.init); static struct SS2 { NS ns1, ns2; } SS2 ss2; assert(ss2.ns1 != NS.init); // line 19 assert(ss2.ns2 != NS.init); static struct SS3 { int i; NS ns; } SS3 ss3; assert(ss3.ns != NS.init); static struct SS4 { int i; NS ns1, ns2; } SS4 ss4; assert(ss4.ns1 != NS.init); // fails assert(ss4.ns2 != NS.init); // fails } --- Exactly same behavior for global templated structs like `struct SS1(T) { T ns; }`.
Comment #1 by k.hara.pg — 2012-11-13T04:20:12Z
Comment #2 by github-bugzilla — 2012-11-13T13:11:29Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/450aeed65f9b9f16186f83eee289dbd885051186 fix Issue 9003 - Nested structs smetimes have null context pointers in static struct https://github.com/D-Programming-Language/dmd/commit/0f91ce38927fc354afe7624bb5f93eb7078d8f49 Merge pull request #1282 from 9rnsr/fix9003 Issue 9003 & 9006 - fill nested struct context pointers