[clang] [clang] Stub out gcc_struct attribute (PR #71148)
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 29 12:32:37 PST 2023
mstorsjo wrote:
> Microsoft bit-field layout didn't break an overly-specific regression test but rendered unusable double to string conversion. The culprit was the following snippet:
>
> ```c++
> union Extractor {
> double value;
> struct {
> bool sign : 1;
> u32 exponent : 11;
> u64 mantissa : 52;
> };
> };
> ```
>
> According to MSVC ABI, there should be padding between fields. I hope you agree that this is not an intuitive and expected behavior.
It is indeed an unexpected thing. However it is possible to work around it for all these cases; if you declare the inner structure like this:
```
struct {
u64 sign : 1;
u64 exponent : 11;
u64 mantissa : 52;
};
```
Then there will be no extra padding between the fields.
https://github.com/llvm/llvm-project/pull/71148
More information about the cfe-commits
mailing list