www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13161] New: Wrong offset of extern(C++) class member


          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 gmail.com
          Reporter: yebblies gmail.com

On linux64 this doesn't print the same offset for val_0 that the C++ version


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 {
    virtual void dummyfunc() {}
    long val_5;
    unsigned val_9;

class Test : public C2d070658_22fb_454d_9aad_35e90299eb2c {
    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;

Jul 19 2014