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]

Re: bool


>>>>> Per Bothner <bothner@cygnus.com> writes:

> Jason Merrill <jason@cygnus.com> writes:
>> Nonsense.  Most uses of bool are to store boolean values.  Most of these
>> values would have been type 'int' if 'bool' were not available.  If you
>> want packed data, you can use a bitvector or 'unsigned char'.

> Most uses of short are to store integer values.  Most of these
> values would have been type 'int' if 'short' were not available.
> What's your point?

My point is that C programmers use int to store flags.  They could use
short or unsigned char, but they use int.  Removing a 'typedef int bool'
and building with g++ should not make their code slower.

Naive users will use bool for a flag, not considering that it might
dramatically slow down an inner loop in their code.  If a knowledgeable
user wants to save space, they can use unsigned char, or a bitvector, or a
bitfield for that matter.

Basically, this is a space/time tradeoff, and there is no right answer.  My
opinion is that time is more important.  And in any case bool has been 4
bytes on RISC targets for the past couple of years, and I don't think it's
worth changing it now.

Jason


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