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
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ea2cde750b4619a579df5ef309210ea9c0d1e734 fix Issue 2481 - mixing field into anonymous struct inside class generates field overlapping vtable
Comment #3 by k.hara.pg — 2013-11-16T02:03:30Z
Worksforme in D2 with test case, and D1 is not supported anymore.