This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Conversion to bool.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]