www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10071] New: 'real' alignment wrong on OS X 32 bit

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10071

           Summary: 'real' alignment wrong on OS X 32 bit
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



PDT ---
---
cat > structsize.cpp <<EOF
#include <stdio.h>
#include <stddef.h>

typedef long double real;

struct S {
  int a;
  real d;
  bool e;
};

S s;

int main() {
  printf("struct size: %lu\n", sizeof(S));
  printf("int offset: %lu\n", offsetof(S, a));
  printf("real offset: %lu\n", offsetof(S, d));
  printf("bool offset: %lu\n", offsetof(S, e));
  return 0;
}
EOF
clang++ -o structsize -m32 structsize.cpp && ./structsize
---

prints
---
struct size: 48
int offset: 0
real offset: 16
bool offset: 32
---

but

---
cat > structsize.d <<EOF
struct S {
    int a;
    real d;
    bool e;
};

pragma(msg, "struct size: ", S.sizeof);
pragma(msg, "int offset: ", S.a.offsetof);
pragma(msg, "real offset: ", S.d.offsetof);
pragma(msg, "bool offset: ", S.e.offsetof);
EOF
dmd -m32 -c structsize.d
---

yields

---
struct size: 32u
int offset: 0u
real offset: 8u
bool offset: 24u
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 12 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10071




PDT ---
(OS X 10.7.5, Clang 3.1/XCode 4.6.2, DMD 2.062/Git master)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 12 2013