How is a bool represented in memory?

Standard states that bool values behave as integral types, yet it doesn’t specify their concrete representation in memory:

“Values of type bool are either true or false. As described below, bool values behave as integral types. Values of type bool participate in integral promotions” ~ C++03 3.9.1 §6

“A synonym for integral type is integer type. The representations of integral types shall define values by use of a pure binary numeration system” ~ C++03 3.9.1 §7

Yet it defines the integral promotion from bool to int:

“An rvalue of type bool can be converted to an rvalue of type int, with false becoming zero and true becoming one. These conversions are called integral promotions.” ~ C++03 4.5 §4-5

as well as conversion from other types to bool:

“A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true.” ~ C++03 4.12 §1

Leave a Comment