Answer found here by a minimal amount of web searching:
Short answer: cout
is interpreting the object as a bool
due to the volatile
qualifier. It's a quirk of overloading for the <<
operator.
Long answer: A volatile pointer can't be converted to a non-volatile pointer without an explicit cast, so neither the char*
nor the void*
overload can be used when the <<
operator is called. There's no volatile qualified overload, and the closest match is the bool
overload, thus your array is interpreted as a boolean value rather than an address or a string.
You can fix it a number of ways, but an explicit cast is probably what you wanted:
std::cout<< (char*)test <
(Personally I would cast to const char*
.)