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;
}