[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 18:00:29 PST 2012


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


Malte Skarupke <malteskarupke at web.de> changed:

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


--- Comment #3 from Malte Skarupke <malteskarupke at web.de> 2012-11-13 18:00:28 PST ---
(In reply to comment #2)
> Seems kinda random actually:
> 
> import std.stdio;
> 
> void main()
> {
>     class C
>     {
>         this(int a)
>         {
>             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(5);
>     c.test();
> }
> 
> ptr: 7FFFF8A0B0A0
> ths: 7FFFF8A0B0A0
> ptr: 7FFFF8A0B0A0
> ths: 7FFFF8A0B0A8

Nevermind, it was explained to me that I am comparing addresses to the pointer
to the class on the stack...

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