Bug 2481 – mixing field into anonymous struct inside class generates field overlapping vtable
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-11-30T13:11:00Z
Last change time
2015-06-09T05:11:39Z
Keywords
wrong-code
Assigned to
nobody
Creator
tomas
Comments
Comment #0 by tomas — 2008-11-30T13:11:29Z
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.
Comment #1 by tomas — 2008-11-30T13:16:08Z
same problem happens if an anonymous union block is used instead
Comment #2 by github-bugzilla — 2013-11-16T00:59:14Z