[Issue 7965] Invalid outer function scope pointer in some cases
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 17 16:48:11 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7965
Nils <mailme+d at nilsb.dyndns.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mailme+d at nilsb.dyndns.org
--- Comment #1 from Nils <mailme+d at nilsb.dyndns.org> 2012-06-17 16:50:24 PDT ---
Seems to me that the default initializer for nested structs misses the context
pointer.
---
void main() {
int x;
struct S {
char y;
void boom() {x = 42;} // makes the struct nested
}
S s;
s.boom();
}
---
There's no crash with an int y, probably because then the struct is considered
to be "all zeros", and is given special treatment. It crashes anyway when y is
explicitly initialized to 0, because the "all zeros" recognizer isn't that
smart
<https://github.com/D-Programming-Language/dmd/blob/aa7939aefcf61d6a44f2d4df15157427f7725fc0/src/struct.c#L532>.
There's no crash if s is initialized to S() or {}.
S.init.boom() crashes, too, of course.
--
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