Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Size of bool unspecified: why?

Reply
Thread Tools

Size of bool unspecified: why?

 
 
MikeP
Guest
Posts: n/a
 
      07-16-2011
Why is the size of 'bool' unspecified? That makes bools pretty useless as
struct members. If one foregoes bools in structs, why not then specify
that bools should be the size of int and thereby likely to be fast to
pass to and from functions? (Is it less efficient to pass
less-than-word-size integers because then they have to be sign-extended
or zero-extended, or any other reason?)


 
Reply With Quote
 
 
 
 
MikeP
Guest
Posts: n/a
 
      07-17-2011
Robert Wessel wrote:
> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <(E-Mail Removed)> wrote:
>
>> Why is the size of 'bool' unspecified? That makes bools pretty
>> useless as struct members. If one foregoes bools in structs, why not
>> then specify that bools should be the size of int and thereby likely
>> to be fast to pass to and from functions? (Is it less efficient to
>> pass less-than-word-size integers because then they have to be
>> sign-extended or zero-extended, or any other reason?)

>
>
> How does the unspecified size of bool make them useless in structs?


How doesn't it?

> The size of ints is also unspecified*, and I use ints in structures
> all the time.


Well, there are structs, and then there are structs.

>
> *except being at least 16 bits - although clearly a minimum exists for
> bools as well.


On VC++ 2010 it is one byte. In some version long ago, it was the size of
int, but probably because that was before the standard declared it could
be unspecified. Let's play a game ("Would you like to play a game? How
about a nice game of chess?" ). If you could have your bool and eat it
too... let me rephrase that: if you could create your own boolean type,
describe it. Describe 2 if you want to: one for C++, and one for your
ideal language that does not yet exist.


 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      07-17-2011
On 07/17/11 05:07 PM, MikeP wrote:
> Robert Wessel wrote:
>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP"<(E-Mail Removed)> wrote:
>>
>>> Why is the size of 'bool' unspecified? That makes bools pretty
>>> useless as struct members. If one foregoes bools in structs, why not
>>> then specify that bools should be the size of int and thereby likely
>>> to be fast to pass to and from functions? (Is it less efficient to
>>> pass less-than-word-size integers because then they have to be
>>> sign-extended or zero-extended, or any other reason?)

>>
>>
>> How does the unspecified size of bool make them useless in structs?

>
> How doesn't it?


It's never bothered me. Why would the size be important? If size and
alignment is important to an environment, the sizes will be specified.

--
Ian Collins
 
Reply With Quote
 
MikeP
Guest
Posts: n/a
 
      07-17-2011
Ian Collins wrote:
> On 07/17/11 05:07 PM, MikeP wrote:
>> Robert Wessel wrote:
>>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP"<(E-Mail Removed)> wrote:
>>>> Why is the size of 'bool' unspecified? That makes bools pretty
>>>> useless as struct members. If one foregoes bools in structs, why
>>>> not then specify that bools should be the size of int and thereby
>>>> likely to be fast to pass to and from functions? (Is it less
>>>> efficient to pass less-than-word-size integers because then they
>>>> have to be sign-extended or zero-extended, or any other reason?)
>>>
>>>
>>> How does the unspecified size of bool make them useless in structs?

>>
>> How doesn't it?

>
> It's never bothered me. Why would the size be important? If size and
> alignment is important to an environment, the sizes will be specified.


I'll return to your post after RW replies.


 
Reply With Quote
 
MikeP
Guest
Posts: n/a
 
      07-17-2011
Robert Wessel wrote:
[whatever the **** he said]

I am not a warrior.

Someone tell Eric C. Weis to GET THE **** OUT OF MY FACE.


> On Sun, 17 Jul 2011 00:07:19 -0500, "MikeP" <(E-Mail Removed)> wrote:
>
>> Robert Wessel wrote:
>>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <(E-Mail Removed)>
>>> wrote:
>>>
>>>> Why is the size of 'bool' unspecified? That makes bools pretty
>>>> useless as struct members. If one foregoes bools in structs, why
>>>> not then specify that bools should be the size of int and thereby
>>>> likely to be fast to pass to and from functions? (Is it less
>>>> efficient to pass less-than-word-size integers because then they
>>>> have to be sign-extended or zero-extended, or any other reason?)
>>>
>>>
>>> How does the unspecified size of bool make them useless in structs?

>>
>> How doesn't it?
>>
>>> The size of ints is also unspecified*, and I use ints in structures
>>> all the time.

>
>
> I give up - how does it? I've used bools in structs. Seemed to work
> just fine. I've used bit fields in structs too, and they're also
> undefined as to what they're actually stored in. That also seemed to
> work.
>
> Both of those, the size of bools, and the storage of bit fields, are
> defined for a particular implementation.
>
>
>> Well, there are structs, and then there are structs.

>
>
> True, but less than informative. I personally find structs containing
> long doubles to be particular impressive - now *those* are *structs*!
>
>
>>>
>>> *except being at least 16 bits - although clearly a minimum exists
>>> for bools as well.

>>
>> On VC++ 2010 it is one byte. In some version long ago, it was the
>> size of int, but probably because that was before the standard
>> declared it could be unspecified. Let's play a game ("Would you like
>> to play a game? How about a nice game of chess?" ). If you could
>> have your bool and eat it too... let me rephrase that: if you could
>> create your own boolean type, describe it. Describe 2 if you want
>> to: one for C++, and one for your ideal language that does not yet
>> exist.

>
>
> Are you talking about interfacing code compiled with different
> versions of the compiler? As a general rule, you shouldn't be mixing
> code from different versions of a C compiler (or equivalently,
> invocations of the C compiler with certain different options), unless
> you restrict yourself to things specified by the system ABI or some
> other ABI that's specified to be valid between the versions in
> question. There are plenty of potential (and allowed)
> incompatibilities in that scenario. Everything from padding to
> alignment, to the storage of bit fields, to the size of ints, to the
> signedness of chars, to calling convention, to name decoration, to the
> format of vtables, to...
>
> Errr... and my "ideal" boolean stores one of two values, and I care
> little about its internal representation. I'd probably pick something
> the size of an int (or whatever my languages equivalent for that is)
> if I cared about speed, a byte or a bit if I cared more about space.
>
> And I really don't mind if you reply to Ian before I reply to you.
> Really I don't.



 
Reply With Quote
 
MikeP
Guest
Posts: n/a
 
      07-17-2011
Robert Wessel wrote:

I meant PUH LEEEEZE! (And go fuk yer mom).


 
Reply With Quote
 
MikeP
Guest
Posts: n/a
 
      07-17-2011
Robert Wessel wrote:
> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <(E-Mail Removed)> wrote:
>
>> Robert Wessel wrote:
>> [whatever the **** he said]
>>
>> I am not a warrior.
>>
>> Someone tell Eric C. Weis to GET THE **** OUT OF MY FACE.

>
>
> Please don't top-post.
>
>
>>> On Sun, 17 Jul 2011 00:07:19 -0500, "MikeP" <(E-Mail Removed)>
>>> wrote:
>>>
>>>> Robert Wessel wrote:
>>>>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <(E-Mail Removed)>
>>>>> wrote:
>>>>>
>>>>>> Why is the size of 'bool' unspecified? That makes bools pretty
>>>>>> useless as struct members. If one foregoes bools in structs, why
>>>>>> not then specify that bools should be the size of int and thereby
>>>>>> likely to be fast to pass to and from functions? (Is it less
>>>>>> efficient to pass less-than-word-size integers because then they
>>>>>> have to be sign-extended or zero-extended, or any other reason?)
>>>>>
>>>>>
>>>>> How does the unspecified size of bool make them useless in
>>>>> structs?
>>>>
>>>> How doesn't it?
>>>>
>>>>> The size of ints is also unspecified*, and I use ints in
>>>>> structures all the time.
>>>
>>>
>>> I give up - how does it? I've used bools in structs. Seemed to
>>> work just fine. I've used bit fields in structs too, and they're
>>> also undefined as to what they're actually stored in. That also
>>> seemed to work.
>>>
>>> Both of those, the size of bools, and the storage of bit fields, are
>>> defined for a particular implementation.
>>>
>>>
>>>> Well, there are structs, and then there are structs.
>>>
>>>
>>> True, but less than informative. I personally find structs
>>> containing long doubles to be particular impressive - now *those*
>>> are *structs*!
>>>
>>>
>>>>>
>>>>> *except being at least 16 bits - although clearly a minimum exists
>>>>> for bools as well.
>>>>
>>>> On VC++ 2010 it is one byte. In some version long ago, it was the
>>>> size of int, but probably because that was before the standard
>>>> declared it could be unspecified. Let's play a game ("Would you
>>>> like to play a game? How about a nice game of chess?" ). If you
>>>> could have your bool and eat it too... let me rephrase that: if
>>>> you could create your own boolean type, describe it. Describe 2 if
>>>> you want to: one for C++, and one for your ideal language that
>>>> does not yet exist.
>>>
>>>
>>> Are you talking about interfacing code compiled with different
>>> versions of the compiler? As a general rule, you shouldn't be
>>> mixing code from different versions of a C compiler (or
>>> equivalently, invocations of the C compiler with certain different
>>> options), unless you restrict yourself to things specified by the
>>> system ABI or some other ABI that's specified to be valid between
>>> the versions in question. There are plenty of potential (and
>>> allowed) incompatibilities in that scenario. Everything from
>>> padding to alignment, to the storage of bit fields, to the size of
>>> ints, to the signedness of chars, to calling convention, to name
>>> decoration, to the format of vtables, to...
>>>
>>> Errr... and my "ideal" boolean stores one of two values, and I care
>>> little about its internal representation. I'd probably pick
>>> something the size of an int (or whatever my languages equivalent
>>> for that is) if I cared about speed, a byte or a bit if I cared
>>> more about space.
>>>
>>> And I really don't mind if you reply to Ian before I reply to you.
>>> Really I don't.


And why don't you get the **** out of my face?


 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      07-17-2011
MikeP <(E-Mail Removed)> wrote:
> Why is the size of 'bool' unspecified?


Probably for the same reason that the size of *any* basic type (with
the exception of char) is unspecified?
 
Reply With Quote
 
James
Guest
Posts: n/a
 
      07-17-2011
"MikeP" <(E-Mail Removed)> wrote in message
news:ivue3c$fp4$(E-Mail Removed)...
>> Robert Wessel wrote:
>> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <(E-Mail Removed)> wrote:

[...]
>
> And why don't you get the **** out of my face?


Are you really that moronic?

Wow! :^)


 
Reply With Quote
 
MikeP
Guest
Posts: n/a
 
      07-18-2011
James wrote:
> "MikeP" <(E-Mail Removed)> wrote in message
> news:ivue3c$fp4$(E-Mail Removed)...
>>> Robert Wessel wrote:
>>> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <(E-Mail Removed)>
>>> wrote: [...]

>>
>> And why don't you get the **** out of my face?

>
> Are you really that moronic?
>
> Wow! :^)


I have my moments\


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Need standard function to do (Bool and Vector) Weng Tianxiang VHDL 2 06-21-2005 12:01 AM
Re: Convert DataRow content to bool Eliyahu Goldin ASP .Net 0 07-07-2003 01:32 PM
Re: Convert DataRow content to bool Ignacio Machin ASP .Net 0 07-07-2003 12:16 PM



Advertisments