http://d.puremagic.com/issues/show_bug.cgi?id=7984
Summary: why is there a hidden field this in nested struct with non-static methods Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: thelastmamm...@gmail.com --- Comment #0 from thelastmamm...@gmail.com 2012-04-25 00:27:20 PDT --- Why is there a hidden field "this" in a struct with non-static methods that is defined in a function? given: void myfunction(){ struct C1{int n; } struct C2{int n; void fun(){}} writeln(C1.init); //prints C(0) writeln(C1.init.sizeof); //prints 4 writeln(C2.init); //prints C(0,null) writeln(C2.init.sizeof); //prints 8 (on 32bit) } In visualD, C2 appears as {n=0 this=0x00000000 }. this only occurs when C2 has at least 1 non-static method. * Why is this, since C2 seems to be a POD ? * the "this" field seems to be always 0x00000000 (from inspection in visualD) * the hidden extra field (and extra size) disappears when C2 is not defined inside a function, or is defined in a class. I couldn't find any related info in the book nor the docs. Thanks! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------