[Issue 24193] A size of unions with struct and bitfields is incompatible with C

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 29 08:06:01 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24193

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
The following:

```
union U {
    struct S {
        int a,b;
    }
    S data;
    int type:8;
}
pragma(msg, U.S.sizeof);
pragma(msg, U.sizeof);
```

prints:

8LU
4LU

Which is, of course, wrong. Curiously, if `int a,b;` is replaced with `long
x;`, it prints:

8LU
8LU

--


More information about the Digitalmars-d-bugs mailing list