logoalt Hacker News

mrkeen • today at 1:54 PM • 1 reply • view on HN

You have some expectations of the size of the bool (it's simply 1 bit but also 8 bits.)

What expectations do you have of the value?


Replies

Panzerschrek • today at 1:58 PM

Bool should be logically 1-bit, when stored in memory only least significant bit should be used and the rest is allowed to be garbage. Such approach gives compilers as much room for optimizations as possible. Forcing them writing some specific bit-pattern may lead to suboptimal code generation.

➕ show 3 replies