http://d.puremagic.com/issues/show_bug.cgi?id=8383
Summary: 64-bit ABI: unions not the same size as in C in some situations Product: D Version: D2 Platform: x86_64 OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: c...@klickverbot.at --- Comment #0 from klickverbot <c...@klickverbot.at> 2012-07-13 02:55:33 PDT --- Originally reported by "bll" at http://www.dsource.org/projects/ldc/ticket/475: --- #include <stdio.h> #include <stdlib.h> union a { long double a1; char ac[20]; }; int main (int argc, char *argv[]) { union a a; printf ("C\n"); printf ("sizeof a: %d\n", sizeof (a)); printf ("sizeof a.a1: %d\n", sizeof (a.a1)); printf ("sizeof a.ac: %d\n", sizeof (a.ac)); printf ("offsetof a.ac: %d\n", (int) ((char *) &a.ac - (char *) &a.a1)); return 0; } --- yields --- C sizeof a: 32 sizeof a.a1: 16 sizeof a.ac: 20 offsetof a.ac: 0 --- but --- import std.stdio; union ua { real a1; char ac[20]; }; int main (string argv[]) { ua a; writefln ("D"); writefln ("sizeof a: %d", a.sizeof); writefln ("sizeof a.a1: %d", a.a1.sizeof); writefln ("sizeof a.ac: %d", a.ac.sizeof); writefln ("offsetof a.ac: %d", a.ac.offsetof); return 0; } --- yields --- D sizeof a: 24 sizeof a.a1: 16 sizeof a.ac: 20 offsetof a.ac: 0 --- when compiling on Linux x86_64. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------