This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Conversion to bool.
- From: Falk Hueffner <hueffner at informatik dot uni-tuebingen dot de>
- To: Jan Ringo¹ <tringi at mx-3 dot cz>
- Cc: <gcc at gnu dot org>
- Date: Mon, 24 May 2004 08:31:28 +0200
- Subject: Re: Conversion to bool.
- References: <001d01c44114$876fd0e0$055f6cc2@merovingian>
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