www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2481] New: mixing field into anonymous struct inside class generates field overlapping vtable

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2481

           Summary: mixing field into anonymous struct inside class
                    generates field overlapping vtable
           Product: D
           Version: 1.035
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


template M() { int i; }
class Z { struct { mixin M!(); } }
void main() { Z z; writefln(z.i.offsetof); }

// output: 0

dmd uses offset=0 internally, meaning that if 'i' is written to, the vtable is
overwritten.


-- 
Nov 30 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2481





------- Comment #1 from tomas famolsen.dk  2008-11-30 13:16 -------
same problem happens if an anonymous union block is used instead


-- 
Nov 30 2008