[Issue 8923] Destructors of struct members get called at the wrong point
http://d.puremagic.com/issues/show_bug.cgi?id=8923 Walter Bright changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8923] Destructors of struct members get called at the wrong point
http://d.puremagic.com/issues/show_bug.cgi?id=8923 --- Comment #4 from github-bugzi...@puremagic.com 2012-11-06 20:31:59 PST --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/585f5a3a3db9f856dc4904910b8a705969b89d33 fix Issue 8923 - Destructors of struct members get called at the wrong point https://github.com/D-Programming-Language/phobos/commit/f76ea73eff85d260f6b1642dbada9701dc3a7fa6 Merge pull request #926 from 9rnsr/fix8923 Supplemental fix for Issue 8923 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8923] Destructors of struct members get called at the wrong point
http://d.puremagic.com/issues/show_bug.cgi?id=8923 --- Comment #5 from github-bugzi...@puremagic.com 2012-11-06 20:33:55 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/704230b135f3e4b25470b4522927fe97a43604c1 fix Issue 8923 - Destructors of struct members get called at the wrong point If a default-initialized variable declaration requies some frame pointers for it's field, they should be initialized by the StructLiteralExp to fill the hidden field. https://github.com/D-Programming-Language/dmd/commit/e1c9119d2a622ecf4bfc3b5c34f20a33f7f4a2c1 Merge pull request #1259 from 9rnsr/fix8923 Issue 8923 - Destructors of struct members get called at the wrong point -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8923] Destructors of struct members get called at the wrong point
http://d.puremagic.com/issues/show_bug.cgi?id=8923 --- Comment #3 from Malte Skarupke 2012-10-31 12:50:17 PDT --- I debugged the issue I was having further, and it is definitely a different problem than I thought it was. It does not have to do with destructors being called in the wrong order, and actually the test case from the first post isn't showing the problem that I encountered. It was just that once I had that test case I felt like I should submit it. I'll try to figure out a test case for my real problem, but I'll do that in a different bug report. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8923] Destructors of struct members get called at the wrong point
http://d.puremagic.com/issues/show_bug.cgi?id=8923 Maxim Fomin changed: What|Removed |Added CC||ma...@maxim-fomin.ru --- Comment #1 from Maxim Fomin 2012-10-31 11:51:58 PDT --- It seems that dmd doesn't pass allocated value correctly. In this case it emits in main function code: callq <_d_allocmemory> movq $0x0,(%rax) movb $0x0,0x8(%rax) lea-0x8(%rbp),%rax xor%rcx,%rcx mov%rcx,(%rax) mov%rax,%rdi So, allocated value is overwritten and destructor gets incorrect pointer in %rdi. However, if the case is simplified to one level (replace S s; with DestructorCounter s;) dmd emits correct code: callq <_d_allocmemory> movq $0x0,(%rax) movb $0x0,0x8(%rax) mov%rax,-0x8(%rbp) lea-0x8(%rbp),%rax xor%rcx,%rcx mov%rax,%rdi Now %rdi points to allocated memory. Probably, because S field destructor doesn't access destructorCalled object forces dmd to pass invalid value. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8923] Destructors of struct members get called at the wrong point
http://d.puremagic.com/issues/show_bug.cgi?id=8923 Kenji Hara changed: What|Removed |Added Keywords||wrong-code --- Comment #2 from Kenji Hara 2012-10-31 11:54:36 PDT --- In Windows, s1's dtor causes Access Violation, but s2's dtor runs successfully. import core.stdc.stdio : printf; void main() { bool destructorCalled = false; struct DestructorCounter { ~this() { printf("-dtor\n"); destructorCalled = true; // segmentation fault } } struct S { DestructorCounter a; } S s1; // Access Violation S s2 = S(); // OK } Output: --- -dtor(s2's dtor call) -dtor(s1's dtor call) object.Error: Access Violation --- I think this is definitely a wrong-code bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---