Topic: bool size
Author: kuehl@kalkofen.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: 1996/12/12 Raw View
Hi,
Chuck May (may@ssims.nci.nih.gov) wrote:
: Does the latest standard state a size of a bool type.
I don't have the latest DWP available but I really doubt that there was
a change. The most recent DWP I have available says this (expr.sizeof
section 1):
[Note: in particular, sizeof(bool) and sizeof(wchar_t)
are implementation-defined.12) ]
...
12) sizeof(bool) is not required to be 1.
[ moderator's note: The current draft says exactly the same thing. -sdc ]
: It seem like it
: should only be one byte, but I have seen it on one compiler as 4
: bytes.
Accesses to one byte entities are more expensive than excesses to
entities of the size of the "natural" machine word: They sometimes cost
more excutation time (more machine cycles) in the access instruction,
or more instructions on RISC machines increasing the requirement on
cache size. Thus, it would definitely be unreasonable on some machines
to define a 'bool' to have the size of a byte. On the other hand, I can
image that there are also CPUs where the fastes method is to use a byte
to represent a 'bool'.
BTW, requiring a 'bool' to have a size of a one byte (in this case as
opposed to have 'sizeof(char)') would rule out some machines: A popular
example of this are some Crays where the smallest addressable entity
has a size of 64 bits, that is on such machines a 'bool' will be
represented as eight bytes although 'sizeof(bool)' will be 1 (because a
'char' also takes eight bytes).
: Should this be standardized?
No, definitely not. If I find that the size of 'bool' is defined to
some number of bytes in the next public DWP, I think I would have to
contact the german representative in the ISO C++ committee...
--
<mailto:dietmar.kuehl@uni-konstanz.de>
<http://www.informatik.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Julian Pardoe <pardoej@lonnds.ml.com>
Date: 1996/12/13 Raw View
Dietmar Kuehl wrote:
> BTW, requiring a 'bool' to have a size of a one byte (in this case as
> opposed to have 'sizeof(char)') would rule out some machines: A popular
> example of this are some Crays where the smallest addressable entity
> has a size of 64 bits, that is on such machines a 'bool' will be
> represented as eight bytes although 'sizeof(bool)' will be 1 (because a
> 'char' also takes eight bytes).
Just to be picky, isn't the term "byte" when used in the standard just
a synonym for "sizeof (char)". Thus in the case you describe a bool
will have a size of one "byte" (in the standard's sense of "byte").
-- jP --
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: may@ssims.nci.nih.gov (Chuck May)
Date: 1996/12/12 Raw View
Does the latest standard state a size of a bool type. It seem like it
should only be one byte, but I have seen it on one compiler as 4
bytes. Should this be standardized? Thanks,
Chuck May
IMS, Inc.
may@ssims.nci.nih.gov
---------------------
Chuck May
IMS, Inc.
may@ssims.nci.nih.gov
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]