Bug 13161 – Wrong offset of extern(C++) class member

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2014-07-19T16:23:00Z
Last change time
2014-08-22T08:04:42Z
Keywords
pull, wrong-code
Assigned to
yebblies
Creator
yebblies

Comments

Comment #0 by yebblies — 2014-07-19T16:23:48Z
On linux64 this doesn't print the same offset for val_0 that the C++ version prints ====================================== import core.stdc.stdio; extern(C++) class C2d070658_22fb_454d_9aad_35e90299eb2c { void dummyfunc() {} long val_5; uint val_9; } extern(C++) class Test : C2d070658_22fb_454d_9aad_35e90299eb2c { uint val_0; long val_1; } void main() { Test s; printf("val_0: %p\n", cast(char*)&s.val_5 - cast(char*)cast(void*)s); printf("val_0: %p\n", cast(char*)&s.val_9 - cast(char*)cast(void*)s); printf("val_0: %p\n", cast(char*)&s.val_0 - cast(char*)cast(void*)s); } ======================================= #include <stdio.h> class C2d070658_22fb_454d_9aad_35e90299eb2c { public: virtual void dummyfunc() {} long val_5; unsigned val_9; }; class Test : public C2d070658_22fb_454d_9aad_35e90299eb2c { public: unsigned val_0; long val_1; }; int main(void) { Test s; printf("val_0: %p\n", (char*)&s.val_5 - (char*)&s); printf("val_0: %p\n", (char*)&s.val_9 - (char*)&s); printf("val_0: %p\n", (char*)&s.val_0 - (char*)&s); return 0; }
Comment #1 by yebblies — 2014-07-19T16:28:51Z
Comment #2 by github-bugzilla — 2014-07-19T20:41:41Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7909a536dbb90c1f265df3418fd1dc3b124601ba Fix Issue 13161 - Wrong offset of extern(C++) class member https://github.com/D-Programming-Language/dmd/commit/3a6133019a2e71a62cc18c8e320e32bc80b709e9 Merge pull request #3785 from yebblies/issue13161 [DDMD] Issue 13161 - Wrong offset of extern(C++) class member
Comment #3 by github-bugzilla — 2014-07-20T20:59:53Z
Commit pushed to 2.066 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2bbe5ee38374a5e6cedad80b2b6cc9c203f75f38 Merge pull request #3785 from yebblies/issue13161 [DDMD] Issue 13161 - Wrong offset of extern(C++) class member
Comment #4 by github-bugzilla — 2014-08-22T08:04:42Z