Thread overview
[Issue 14442] Wrong this.outer reference in nested classes
Apr 13, 2015
Iain Buclaw
Apr 13, 2015
Iain Buclaw
Apr 13, 2015
Dicebot
Apr 13, 2015
Iain Buclaw
Dec 14, 2015
Kenji Hara
April 13, 2015
https://issues.dlang.org/show_bug.cgi?id=14442

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, diagnostic
                 CC|                            |ibuclaw@gdcproject.org

--
April 13, 2015
https://issues.dlang.org/show_bug.cgi?id=14442

--- Comment #1 from Iain Buclaw <ibuclaw@gdcproject.org> ---
Also affects the debug code written.  As all you see of this parent chain is garbage values.


(gdb) p this
$1 = (__anonclass1 &) @0x7ffff7ed5fc0:
{
  <Object> = {
    __vptr = 0x4890e0 <vtable nested.Foo35.bar().__anonclass1>,
    __monitor = 0x0
  },
  this = @0x7ffff7ed6ff0    // <-- closure pointer
}
(gdb) p this.this
$2 = (Foo35 &) @0x7ffff7ed6ff0:
{
  <Object> = {
    __vptr = 0x7ffff7ed5fe0,    // <-- Foo35 object reference
    __monitor = 0x2b    // <-- 'y' value
  },
  x = 0    // <-- Excess garbage
}

--
April 13, 2015
https://issues.dlang.org/show_bug.cgi?id=14442

Dicebot <public@dicebot.lv> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |public@dicebot.lv

--- Comment #2 from Dicebot <public@dicebot.lv> ---
Is it effectively another manifestation of "have one context pointer, need many" issue?

--
April 13, 2015
https://issues.dlang.org/show_bug.cgi?id=14442

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Dicebot from comment #2)
> Is it effectively another manifestation of "have one context pointer, need many" issue?

Maybe... though in this scenario you can get away with just the one context pointer:

anonclass this
{
    void *this (bar.__closptr)
    {
        Foo35 this
        {
            int x = 42;
        }
        int y = 43;
    }
}


So you know that the following:

assert(x == 42);
assert(y == 43);

Is lowered to:

assert((cast(Foo35)(*cast(CLOSURE bar *)this.this)).x == 42);
assert((cast(CLOSURE bar *)this.this).y == 43);

--
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=14442

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D2

--
December 14, 2015
https://issues.dlang.org/show_bug.cgi?id=14442

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
This would be a root of issue 15422. Will be fixed by: https://github.com/D-Programming-Language/dmd/pull/5308

--
February 01, 2016
https://issues.dlang.org/show_bug.cgi?id=14442

--- Comment #5 from github-bugzilla@puremagic.com ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8c60fe029f576efacc7bd15f6bec52d0d652c97c fix Issue 14442 - Wrong this.outer reference in nested classes

--
February 01, 2016
https://issues.dlang.org/show_bug.cgi?id=14442

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--