Thread overview
[Issue 24193] Incorrect size of unions with bit fields
[Issue 24193] A size of unions with struct and bitfields is incompatible with C
Oct 29, 2023
Walter Bright
Oct 30, 2023
Walter Bright
Oct 30, 2023
Walter Bright
Oct 30, 2023
Dlang Bot
Oct 30, 2023
Dlang Bot
October 29, 2023
https://issues.dlang.org/show_bug.cgi?id=24193

Walter Bright <bugzilla@digitalmars.com> changed:

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

--- Comment #1 from Walter Bright <bugzilla@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

--
October 30, 2023
https://issues.dlang.org/show_bug.cgi?id=24193

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|A size of unions with       |Incorrect size of unions
                   |struct and bitfields is     |with bit fields
                   |incompatible with C         |

--
October 30, 2023
https://issues.dlang.org/show_bug.cgi?id=24193

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Not specific to C, it equally affects D.

--
October 30, 2023
https://issues.dlang.org/show_bug.cgi?id=24193

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15750 "fix Issue 24193 - Incorrect size of unions with bit fields" fixing this issue:

- fix Issue 24193 - Incorrect size of unions with bit fields

https://github.com/dlang/dmd/pull/15750

--
October 30, 2023
https://issues.dlang.org/show_bug.cgi?id=24193

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15750 "fix Issue 24193 - Incorrect size of unions with bit fields" was merged into master:

- 0f96f556335ae162673f4c0e11be0365594ba7a8 by Walter Bright:
  fix Issue 24193 - Incorrect size of unions with bit fields

https://github.com/dlang/dmd/pull/15750

--