second draft: add Bitfields to D

Patrick Schluter Patrick.Schluter at bbox.fr
Fri May 3 12:52:09 UTC 2024


On Tuesday, 30 April 2024 at 03:30:15 UTC, Walter Bright wrote:
> On 4/29/2024 5:04 AM, Timon Gehr wrote:
>>> If they are not checking for bitfields, but are just looking 
>>> at .offsetof and the type, they'll interpret the bitfields as 
>>> a union (which, in a way, is accurate).
>>> ...
>> 
>> No, it is not accurate.
>
> Getting and setting bit fields reads/writes all the bits in the 
> underlying field, so it definitely is like a union. 
> std.bitmanip.bitfields also implements it as a union, because 
> there is no other way. The CPU does not provide any 
> instructions to access bit fields.
>
Not true. x86 provides BMI1 instructions which are present in x86 
CPUs at least since 2013.
ARM also provides bit field instructions and quite a number of 
legacy CPU's also had bitfield instructions (m68k, NEC V30, 
Itanium, PowerPC, etc.).
Doesn't change the issues with language bitfields



More information about the dip.development mailing list