Bug 19307 – Variables moved to a closure show nonsense in debugger
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2018-10-16T06:10:31Z
Last change time
2018-10-26T09:16:59Z
Keywords
pull, symdeb
Assigned to
No Owner
Creator
Rainer Schuetze
Comments
Comment #0 by r.sagitario — 2018-10-16T06:10:31Z
Compile this program with -g:
int main()
{
int x = 7;
auto dg = delegate() {
return x;
};
return dg();
}
and step through it in a debugger: the assignment to x does not seem to do anyhing, the value of 'x' stays random.
Comment #1 by r.sagitario — 2018-10-16T06:13:11Z
This is caused by 'x' being emitted as if it is still accessed via the frame pointer. This is the relevant snippet form the cvdump output:
(000024) S_GPROC32: [0001:00009F10], Cb: 0000004F, Type: 0x1003, D main
Parent: 00000000, End: 00000094, Next: 00000000
Debug start: 00000008, Debug end: 0000004A
(000054) S_ENDARG
(000058) S_REGREL32: rbp+FFFFFFE0, Type: 0x3BF6, __closptr
(000070) S_REGREL32: rbp+FFFFFFE8, Type: 0x1006, x
(000080) S_REGREL32: rbp+FFFFFFF0, Type: 0x100A, dg