Tried compiling my simple example in a different project and it worked. Spent awhile trying to trace the problem back and it turns out in one of the constructors for my class I didn't assign a value to the bool.
Could an uninitialised bool have the same effect as any other uninitialised variable?
The OP didn't seem to provide a constructor (but long double main did), so an implicit one would be used, aren't the member variables initialised to some default value hence the purpose of using initialiser lists?
If it is, then I guess we could spend all day trying explain UB and not get anywhere :+)
Any way what displaying them with boolalpha? I am thinking it is some thing perverse with the way cout displays them versus the actual implementation and / or that they are separate objects.
Sorry if I sound lazy, but you have the code :+)
Probably wasting out time if it is UB, so only if you are bored.
> No matter the values of foo the output is always
> 204:204
> not equal
>> But that doesn't explain why the value printed is 204 rather than 1 or 0.
>>> I'm not sure how to explain the fact that the OP got 204 for both of them
>>> and it still came out to be not equal.
>>>> I am thinking it is some thing perverse with the way cout displays them
Footnote: 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. - IS
There is not much point in reading the IS like a text book.
Learning how to find things in it is useful; to get a doubt clarified, or to check if there really is a bug that ought to be reported to the compiler vendor.