[Issue 9020] This pointer is not the same in constructor as it is in invariant

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 13 17:35:27 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9020


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com
            Summary|This pointer is not the     |This pointer is not the
                   |same in constructor as it   |same in constructor as it
                   |is in methods               |is in invariant


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-11-13 17:35:26 PST ---
This seems to only happen in the invariant, not in methods:

import std.stdio;

void main()
{
    class C
    {
        this()
        {
            this_pointer = &this;
            writefln("ptr: %X", this_pointer);
            writefln("ths: %X", &this);
        }

        void test()
        {
            writefln("ptr: %X", this_pointer);
            writefln("ths: %X", &this);
        }

        C* this_pointer;
    }

    C c = new C;
    c.test();
}

Log:
ptr: 12FE44
ths: 12FE44
ptr: 12FE44
ths: 12FE44

-- 
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