3 ms·
Yeah they compile to the same machine code operations though. If those machine code operations aren't right as a bitfield then they aren't going to be right don
by chrisseaton 5y ago
Yeah they compile to the same machine code operations though. If those machine code operations aren't right as a bitfield then they aren't going to be right done manually either.
https://godbolt.org/z/csvTx89EG https://godbolt.org/z/csvTx89EG
- layer8 5y agoBit field support being buggy exactly means that they don’t compile to the same machine code as the bit shifting/masking code you would write by hand (if your hand-written code is correct).
- minipci1321 5y ago> Yeah they compile to the same machine code operations though. Not always. Switch your example to AARCH64 and check out the BFI instruction.
- alcover 5y agoIs it not rather void bar(struct y *s, unsigned int foo) { s->c = (s->c & 0xf0) | foo; }
- tom_ 5y agoARM is little-endian, and by tradition bitfield bit indexes are assigned from least significant (bit 0 in ARM terms) to more significant. b occupies bits 4-7 inclusive.