digitalmars.D.bugs - [Issue 19381] New: capture pointer in nested function should not be
- d-bugmail puremagic.com (60/60) Nov 09 2018 https://issues.dlang.org/show_bug.cgi?id=19381
https://issues.dlang.org/show_bug.cgi?id=19381 Issue ID: 19381 Summary: capture pointer in nested function should not be called "this" Product: D Version: D2 Hardware: All OS: Windows Status: NEW Keywords: symdeb Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: r.sagitario gmx.de struct Struct { int x = 3; int foo() { int y = 5; int nested() { int z = 7; return x + y + z; } return nested(); } } int main() { return Struct().foo(); } When compiled with -g, this shows a variable in nested() called "this", but is not the struct, but the capture of the outer function: (00004C) S_GPROC32: [0000:00000000], Cb: 0000002B, Type: 0x1004, dg.Struct.foo.nested Parent: 00000000, End: 00000000, Next: 00000000 Debug start: 0000000C, Debug end: 00000026 (000088) S_REGREL32: rbp+00000010, Type: 0x1019, this (0000A0) S_ENDARG (0000A4) S_REGREL32: rbp+FFFFFFF8, Type: T_INT4(0074), z (0000B4) S_END The type of "this" used to be void*, but has recently been populated with the captured stack variables of the outer function: 0x1016 : Length = 42, Leaf = 0x1505 LF_STRUCTURE Derivation list type 0x0000, VT shape type 0x0000 Size = 0, class name = CAPTURE.dg.Struct.foo 0x1017 : Length = 34, Leaf = 0x1203 LF_FIELDLIST list[0] = LF_MEMBER, public, type = 0x1015, offset = 16 member name = 'this' list[1] = LF_MEMBER, public, type = 0x1002, offset = (LF_SHORT) -8 member name = 'y' 0x1019 : Length = 10, Leaf = 0x1002 LF_POINTER Pointer (__ptr64), Size: 8 Element type : 0x1016 Note the "this" member of the capture struct. Having multiple "this" variables confuses both the debugger and the user. --
Nov 09 2018