This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bool
- To: egcs at cygnus dot com
- Subject: Re: bool
- From: Per Bothner <bothner at cygnus dot com>
- Date: Tue, 11 Nov 1997 10:45:00 -0800
Andrew Borthwick <borthwic@johnson.cs.nyu.edu>:
> I wrote a little test program and found that with the 1997/11/05 snapshot,
> a bool has a size of 4 bytes.
I had thought this was fixed.
If not, it really should be. sizeof(bool) must be one.
Any other choice will be "unexpected" by reasonable progragrammers.
Whether it takes more time to load a one-byte bool than a 4-byte
or 8-byte bool is irrelevant - otherwise, we should make short
be 4 bytes as well.
While saying that, I do think you may be confused. You say:
> "sizeof(vector<bool>)" gives a size of 28 bytes as did "sizeof(bit_vector)".
Er - what has sizeof to do with how bits are packed? Obviously, sizeof
will only tell you the fixed (overhead) size. If you look at
bit_vector, you will find that it does use 1 bit per bool.
--Per Bothner
Cygnus Solutions bothner@cygnus.com http://www.cygnus.com/~bothner