It's not just less memory though - it might also introduce spurious data dependencies, e.g. to store a bit you now need to also read the old value of the byte that it's in.
timhh
joined 5 days ago
I don't think so. Apart from dynamically typed languages which need to store the type with the value, it's always 1 byte, and that doesn't depend on architecture (excluding ancient or exotic architectures) or optimisation flags.
Which language/architecture/flags would not store a bool in 1 byte?
No it isn't. All statically typed languages I know of use a byte. Which languages store it in an entire 32 bits? That would be unnecessarily wasteful.
Well there are containers that store booleans in single bits (e.g. std::vector<bool>
- which was famously a big mistake).
But in the general case you don't want that because it would be slower.
You can't store data in parity bits... so it's irrelevant.