I can't find an answer in the standard documentation. Does the C++ language standard require sizeof(bool)
to always be 1 (for 1 byte), or is this size implementation-defined?
sizeof(bool)
is implementation defined, and the standard puts notable emphasis on this fact.
§5.3.3/1, abridged:
sizeof(char)
,sizeof(signed char)
andsizeof(unsigned char)
are 1; the result ofsizeof
applied to any other fundamental type is implementation-defined. [Note: in particular,sizeof(bool)
andsizeof(wchar_t)
are implementation-defined.69)]
Footnote 69):
sizeof(bool)
is not required to be 1.