[Issue 9003] New: Nested structs smetimes have null context pointers in static struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 12 04:59:39 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9003
Summary: Nested structs smetimes have null context pointers in
static struct
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: verylonglogin.reg at gmail.com
--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2012-11-12 15:59:31 MSK ---
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; }`.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list