Package: gdc-4.1
Version: 0.25-4.1.2-23.2
Severity: normal

gdc on i386 inserts four bytes of padding in this struct (so that it's
total size is 16 bytes), while gcc doesn't:

struct test {
  int mode;
  double mu;
};

According to http://www.digitalmars.com/d/1.0/abi.html, structs should
conform "to the target's C ABI struct layout", so it looks like this
is a bug.

Two small test programs are attached.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/1 CPU core)
Locale: LANG=nl_BE.UTF-8, LC_CTYPE=nl_BE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gdc-4.1 depends on:
ii  g++-4.1                  4.1.2-25        The GNU C++ compiler
ii  gcc-4.1-base             4.1.2-25        The GNU Compiler Collection (base 
ii  libc6                    2.9-6           GNU C Library: Shared libraries
ii  libgcc1                  1:4.3.3-5       GCC support library
ii  libphobos-4.1-dev        0.25-4.1.2-23.2 The phobos D standard library
ii  libstdc++6               4.3.3-5         The GNU Standard C++ Library v3

gdc-4.1 recommends no packages.

gdc-4.1 suggests no packages.

-- no debconf information
import std.stdio;

extern(C)
struct test {
  int mode;
  double mu;
};

void main()
{
  writefln("test.sizeof: ", test.sizeof);
  writefln("test.mode.offsetof: ", test.mode.offsetof);
  writefln("test.mu.offsetof: ", test.mu.offsetof);
}
#include <stdio.h>
#include <stddef.h>

struct test {
  int mode;
  double mu;
};

int main()
{
  printf("test.sizeof: %zd\n", sizeof(struct test));
  printf("test.mode.offsetof: %zd\n", offsetof(struct test, mode));
  printf("test.mu.offsetof: %zd\n", offsetof(struct test, mu));
  return 0;
}

Reply via email to