Conversion to bool.

Falk Hueffner hueffner@informatik.uni-tuebingen.de
Mon May 24 06:34:00 GMT 2004


Jan Ringo¹ <tringi@mx-3.cz> writes:

> I come to this thing. I know that bools are actually stored as bytes

Actually, it depends on the ABI. But most do in fact use 1 byte.

> but logicaly they are single bits. Shouldn't then assignment of
> whatever nonnull to bool be always 1?

Yes, it should. Do you have an example where this is not the case?
Then please file a bug.

> And also shouldn't
> bool b = *(bool*)&number;
> copy only the lowest bit of number?

No, it shouldn't, since this code is only valid code if number is a
bool, in which case it is usually faster to copy the whole byte.

-- 
	Falk



More information about the Gcc mailing list