[Cxx-abi-dev] Overlong bit fields and 128-bit integers
Dennis Handly
dhandly at cup.hp.com
Fri Sep 23 04:34:19 UTC 2011
>From: David Vandevoorde <daveed at edg.com>
>As you can tell from the subject line keywords we're well in "odd corner
>case" territory here, but we received an ABI compatibility problem
>report in this area.
Yes, we found this using Code Sourcery's ABI test suite.
Consider:
struct S {
int i;
long long x: 130;
int j;
};
What's the offset of j?
>Here we're dealing with the second bullet because sizeof(long long)*8 <
>130 (long long is 8 bytes). We emulate GCC modes that permit 128-bit
integral types, and in those modes, T' is __int128, a 16-byte aligned
>type. That means that the addition of __int128 has changed the layout
>of a structure that doesn't involve __int128 at all!
Yes, that was most discouraging. And not forward compatible, by just adding
wider types.
>GCC keeps the alignment of the bit field at an 8-byte boundary in this
>case, and that makes sense to me, but for:
struct S2 {
int i;
__int128 x: 130;
int j;
};
>it does the same, which does not make sense to me: If I used a __int128
>type for the field, I presumably want the associated alignment used.
Right.
>I'd like to therefore propose changing this such that:
>- for standard C++11 integral types use the existing rule
> - for integral types not defined in C++11, limit T' to the standard
>C++11 types and the declared bit field container type
>What do you all think?
Daveed
Sounds good. Do we know who will be broken after this change?
gcc is the above broken case of __int128?
More information about the cxx-abi-dev
mailing list