The standard does not guarantee that bool
is at all compatible with char
(i.e. it does not guarantee that they have the same size or alignment), saying:
Values of type bool
are either true
or false
.
§3.9.1 [basic.fundamental]
It also says:
Using a bool
value in ways described by this International Standard as “undefined,” such as by examining the value of an uninitialized automatic object, might cause it to behave as if it is neither true
nor false
.
Footnote 47 (N3337)
Therefore you are in the realm of undefined behaviour.
Note that since the standard does not make an exception for bool
, the following rules apply:
If a program attempts to access the stored value of an object through a glvalue of other than one of the following types the behavior is undefined:
— the dynamic type of the object,
— a cv-qualified version of the dynamic type of the object,
— a type similar (as defined in 4.4) to the dynamic type of the object,
— a type that is the signed or unsigned type corresponding to the dynamic type of the object,
— a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of the object,
— an aggregate or union type that includes one of the aforementioned types among its elements or nonstatic data members (including, recursively, an element or non-static data member of a subaggregate or contained union),
— a type that is a (possibly cv-qualified) base class type of the dynamic type of the object,
— a char or unsigned char type.
§3.10 [basic.lval]
The types of the objects in this case are unsigned char
, therefore attempting to access them through a bool
lvalue (which is what you obtain by dereferencing a bool *
) leads to UB.