[Issue 13161] New: Wrong offset of extern(C++) class member
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jul 19 09:23:48 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13161
Issue ID: 13161
Summary: Wrong offset of extern(C++) class member
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Keywords: wrong-code
Severity: critical
Priority: P1
Component: DMD
Assignee: yebblies at gmail.com
Reporter: yebblies at gmail.com
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;
}
--
More information about the Digitalmars-d-bugs
mailing list