[Issue 9834] template+class+FunctionLiteral=AccessViolation
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 30 13:09:28 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9834
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2013-03-30 13:09:28 PDT ---
Ok, I found the root cause.
version(bad) void set(void delegate() h) pure { dg = h; } // AV occurs
else void set(void delegate() h) { dg = h; } // no AV
// -version=bad
c:\d\test.d:14 this() {
004020ec: 55 push ebp
004020ed: 8bec mov ebp, esp
004020ef: 83ec04 sub esp, 0x4
004020f2: 53 push ebx
004020f3: 56 push esi
004020f4: 8945fc mov [ebp-0x4], eax
c:\d\test.d:15 o = new Object;
004020f7: b880f34100 mov eax, 0x41f380
004020fc: 50 push eax
004020fd: e87e020000 call 0x402380 __d_newclass
00402102: 8b4dfc mov ecx, [ebp-0x4]
00402105: 894108 mov [ecx+0x8], eax
c:\d\test.d:16 ev.set((){
00402108: ba2c214000 mov edx, 0x40212c
0040210d: 52 push edx
0040210e: 8d5dfc lea ebx, [ebp-0x4]
00402111: 53 push ebx
00402112: 8b75fc mov esi, [ebp-0x4]
00402115: 8b460c mov eax, [esi+0xc]
00402118: 83c004 add eax, 0x4
0040211b: e8f0feffff call 0x402010 test.Event.set c:\d\test.d:6
00402120: 8b45fc mov eax, [ebp-0x4]
00402123: 83c404 add esp, 0x4
c:\d\test.d:19 }
00402126: 5e pop esi
00402127: 5b pop ebx
00402128: c9 leave
00402129: c3 ret
c:\d\test.d:14 this() {
004020ec: 55 push ebp
004020ed: 8bec mov ebp, esp
004020ef: 83ec08 sub esp, 0x8
004020f2: 53 push ebx
004020f3: 56 push esi
004020f4: 8945fc mov [ebp-0x4], eax
004020f7: 6a08 push 0x8 <--
004020f9: e8ee020000 call 0x4023ec __d_allocmemory <--
004020fe: 8945f8 mov [ebp-0x8], eax <--
00402101: 8b4dfc mov ecx, [ebp-0x4] <--
00402104: 8908 mov [eax], ecx <--
00402106: 8b55fc mov edx, [ebp-0x4] <--
00402109: 895004 mov [eax+0x4], edx <--
c:\d\test.d:15 o = new Object;
0040210c: bb80f34100 mov ebx, 0x41f380
00402111: 53 push ebx
00402112: e87d020000 call 0x402394 __d_newclass
00402117: 8b75fc mov esi, [ebp-0x4]
0040211a: 894608 mov [esi+0x8], eax
c:\d\test.d:16 ev.set((){
0040211d: b840214000 mov eax, 0x402140
00402122: 50 push eax
00402123: ff75f8 push dword [ebp-0x8]
00402126: 8b4dfc mov ecx, [ebp-0x4]
00402129: 8b410c mov eax, [ecx+0xc]
0040212c: 83c004 add eax, 0x4
0040212f: e8dcfeffff call 0x402010 test.Event.set c:\d\test.d:7
00402134: 8b45fc mov eax, [ebp-0x4]
00402137: 83c408 add esp, 0x8
c:\d\test.d:19 }
0040213a: 5e pop esi
0040213b: 5b pop ebx
0040213c: c9 leave
0040213d: c3 ret
With -version=bad, heap allocation for closure variable does not performed.
Therefore, compiler wrongly judges that the lambda (){o.toString();} is "scope
delegate".
--
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