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?
C++ – Is sizeof(bool) defined in the C++ language standard
booleancimplementation-defined-behaviorsizeof
Related Topic
- C++ – How to iterate over the words of a string
- C++ – The Definitive C++ Book Guide and List
- C++ – the “–>” operator in C/C++
- C++ – Why the sizeof(bool) is not defined to be one, by the Standard itself
- C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming
- Python – Why is reading lines from stdin much slower in C++ than Python
- C++ – Can code that is valid in both C and C++ produce different behavior when compiled in each language
- C++ – Does the C++ standard allow for an uninitialized bool to crash a program
Best Answer
sizeof(bool)
is implementation defined, and the standard puts notable emphasis on this fact.§5.3.3/1, abridged:
Footnote 69):