C bitfields guarantees

Walter Bright newshound2 at digitalmars.com
Mon Jul 8 23:52:39 UTC 2024


On 7/7/2024 3:42 AM, Timon Gehr wrote:
> If it is simple, you should have no trouble stating how it works completely in a 
> couple sentences.

One sentence:

If the bitfields of type T start on a T alignment boundary and do not straddle a 
T alignment boundary, then the bitfields will be portable.

I agree I sometimes have trouble writing exact specifications, but I'm also 
confident that you understand this.


> I am as a result now not sure whether what you stated is the full truth, or it is still 
> some inadmissible simplification that glosses over some further dragons.

Feel free to try pathological examples and let me know of any adverse discoveries.


> Also, I hope `.offsetof % .alignof != 0` is just a bug in your bitfield 
> implementation.

??



More information about the Digitalmars-d mailing list