Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7870 > unrolled thread

Size of bool unspecified: why?

Started by"MikeP" <mp011011@some.org>
First post2011-07-16 05:33 -0500
Last post2011-07-22 12:28 -0700
Articles 18 on this page of 78 — 12 participants

Back to article view | Back to comp.lang.c++


Contents

  Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-16 05:33 -0500
    Re: Size of bool unspecified: why? BGB <cr88192@hotmail.com> - 2011-07-16 10:02 -0700
      Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-20 13:05 -0700
        Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-20 15:46 -0500
          Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-21 09:01 +1200
            Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-20 19:32 -0500
              Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-21 14:46 +1200
                Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-20 23:28 -0500
                  Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-21 16:43 +1200
                    Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 02:56 -0500
                      Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-21 20:19 +1200
                        Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 18:29 -0500
                          Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-22 11:40 +1200
                            Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 22:33 -0500
                              Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-22 15:46 +1200
                                Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 23:07 -0500
                                  Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-22 16:12 +1200
                                    Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-31 18:45 +1200
                          Re: Size of bool unspecified: why? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-22 00:12 -0700
                            Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 11:10 -0700
                              Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-22 16:52 -0500
                                Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-23 09:55 +1200
                          Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 11:01 -0700
                            Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-22 17:17 -0500
                              Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-23 10:46 +1200
                              Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-24 03:48 -0700
                                Re: Size of bool unspecified: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-24 12:40 -0500
                                  Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-30 11:22 -0700
                                    Re: Size of bool unspecified: why? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-07-31 02:33 +0200
                                Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-30 11:34 -0700
                            Re: Size of bool unspecified: why? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-07-25 04:46 +0200
                  Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-21 07:23 -0700
                    Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 18:52 -0500
                      Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 11:24 -0700
                        Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-22 17:22 -0500
                          Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-23 10:51 +1200
                    Re: Size of bool unspecified: why? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-22 00:17 -0700
                      Re: Size of bool unspecified: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-22 04:26 -0500
              Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-21 02:09 -0700
                Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 19:11 -0500
                  Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 11:58 -0700
                    Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-22 17:48 -0500
              Re: Size of bool unspecified: why? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-21 08:41 -0700
                Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 19:14 -0500
                  Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 12:01 -0700
                    Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-22 17:51 -0500
          Re: Size of bool unspecified: why? Noah Roberts <dont@email.me> - 2011-07-20 16:57 -0700
            Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-21 07:29 -0700
              Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 19:24 -0500
                Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-22 12:33 +1200
                  Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 22:42 -0500
          Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-21 01:59 -0700
            Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 19:42 -0500
              Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 12:20 -0700
                Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-22 18:21 -0500
    Re: Size of bool unspecified: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-16 22:23 -0500
      Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-17 00:07 -0500
        Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-17 17:15 +1200
          Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-17 00:24 -0500
        Re: Size of bool unspecified: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-17 02:02 -0500
          Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-17 03:02 -0500
            Re: Size of bool unspecified: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-17 03:23 -0500
              Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-17 05:36 -0500
                Re: Size of bool unspecified: why? "James" <no@spam.invalid> - 2011-07-17 16:24 -0700
                  Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-18 06:49 -0500
                    Re: Size of bool unspecified: why? "James" <no@spam.invalid> - 2011-07-18 16:46 -0700
                    Re: Size of bool unspecified: why? Ian Collins <ian-news@hotmail.com> - 2011-07-19 11:59 +1200
                      Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-19 22:18 -0500
          Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-17 03:04 -0500
        Re: Size of bool unspecified: why? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-22 00:32 -0700
        Re: Size of bool unspecified: why? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-22 00:41 -0700
    Re: Size of bool unspecified: why? Juha Nieminen <nospam@thanks.invalid> - 2011-07-17 13:50 +0000
      Re: Size of bool unspecified: why? "MikeP" <mp011011@some.org> - 2011-07-18 06:50 -0500
        Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-20 13:06 -0700
      Re: Size of bool unspecified: why? Pawel Dziepak <pdziepak@quarnos.org> - 2011-07-21 12:59 +0000
        Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-21 07:11 -0700
          Re: Size of bool unspecified: why? "JBarleycorn" <jbnh2o@newsnet.org> - 2011-07-21 19:21 -0500
            Re: Size of bool unspecified: why? James Kanze <james.kanze@gmail.com> - 2011-07-22 12:28 -0700

Page 4 of 4 — ← Prev page 1 2 3 [4]


#7914

From"MikeP" <mp011011@some.org>
Date2011-07-17 03:02 -0500
Message-ID<ivu52b$vf$1@dont-email.me>
In reply to#7910
Robert Wessel wrote:
[whatever the fuck he said]

I am not a warrior.

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


> On Sun, 17 Jul 2011 00:07:19 -0500, "MikeP" <mp011011@some.org> wrote:
>
>> Robert Wessel wrote:
>>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <mp011011@some.org>
>>> 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. 

[toc] | [prev] | [next] | [standalone]


#7916

FromRobert Wessel <robertwessel2@yahoo.com>
Date2011-07-17 03:23 -0500
Message-ID<bu6527dtpldj9mj4arfi6067n9l7qahcll@4ax.com>
In reply to#7914
On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <mp011011@some.org> wrote:

>Robert Wessel wrote:
>[whatever the fuck he said]
>
>I am not a warrior.
>
>Someone tell Eric C. Weis to GET THE FUCK OUT OF MY FACE.


Please don't top-post.


>> On Sun, 17 Jul 2011 00:07:19 -0500, "MikeP" <mp011011@some.org> wrote:
>>
>>> Robert Wessel wrote:
>>>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <mp011011@some.org>
>>>> 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. 
>

[toc] | [prev] | [next] | [standalone]


#7919

From"MikeP" <mp011011@some.org>
Date2011-07-17 05:36 -0500
Message-ID<ivue3c$fp4$1@dont-email.me>
In reply to#7916
Robert Wessel wrote:
> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <mp011011@some.org> wrote:
>
>> Robert Wessel wrote:
>> [whatever the fuck he said]
>>
>> I am not a warrior.
>>
>> Someone tell Eric C. Weis to GET THE FUCK OUT OF MY FACE.
>
>
> Please don't top-post.
>
>
>>> On Sun, 17 Jul 2011 00:07:19 -0500, "MikeP" <mp011011@some.org>
>>> wrote:
>>>
>>>> Robert Wessel wrote:
>>>>> On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <mp011011@some.org>
>>>>> 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 fuck out of my face? 

[toc] | [prev] | [next] | [standalone]


#7929

From"James" <no@spam.invalid>
Date2011-07-17 16:24 -0700
Message-ID<ivvqu4$3gi$1@speranza.aioe.org>
In reply to#7919
"MikeP" <mp011011@some.org> wrote in message 
news:ivue3c$fp4$1@dont-email.me...
>> Robert Wessel wrote:
>> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <mp011011@some.org> wrote:
[...]
>
> And why don't you get the fuck out of my face?

Are you really that moronic?

Wow!  :^) 

[toc] | [prev] | [next] | [standalone]


#7932

From"MikeP" <mp011011@some.org>
Date2011-07-18 06:49 -0500
Message-ID<j016je$7s1$1@dont-email.me>
In reply to#7929
James wrote:
> "MikeP" <mp011011@some.org> wrote in message
> news:ivue3c$fp4$1@dont-email.me...
>>> Robert Wessel wrote:
>>> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <mp011011@some.org>
>>> wrote: [...]
>>
>> And why don't you get the fuck out of my face?
>
> Are you really that moronic?
>
> Wow!  :^)

I have my moments\ 

[toc] | [prev] | [next] | [standalone]


#7948

From"James" <no@spam.invalid>
Date2011-07-18 16:46 -0700
Message-ID<j02gjo$iqs$1@speranza.aioe.org>
In reply to#7932
"MikeP" <mp011011@some.org> wrote in message 
news:j016je$7s1$1@dont-email.me...
> James wrote:
>> "MikeP" <mp011011@some.org> wrote in message
>> news:ivue3c$fp4$1@dont-email.me...
>>>> Robert Wessel wrote:
>>>> On Sun, 17 Jul 2011 03:02:15 -0500, "MikeP" <mp011011@some.org>
>>>> wrote: [...]
>>>
>>> And why don't you get the fuck out of my face?
>>
>> Are you really that moronic?
>>
>> Wow!  :^)
>
> I have my moments\

;^) 

[toc] | [prev] | [next] | [standalone]


#7950

FromIan Collins <ian-news@hotmail.com>
Date2011-07-19 11:59 +1200
Message-ID<98jvoeF8muU3@mid.individual.net>
In reply to#7932
On 07/18/11 11:49 PM, MikeP wrote:
> James wrote:
>>
>> Are you really that moronic?
>>
>> Wow!  :^)
>
> I have my moments\

Some moments are best enjoyed in private.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#7994

From"MikeP" <mp011011@some.org>
Date2011-07-19 22:18 -0500
Message-ID<j05hf3$b7j$1@dont-email.me>
In reply to#7950
Ian Collins wrote:
> On 07/18/11 11:49 PM, MikeP wrote:
>> James wrote:
>>>
>>> Are you really that moronic?
>>>
>>> Wow!  :^)
>>
>> I have my moments\
>
> Some moments are best enjoyed in private.

When one Mr. John Daniels invites you to have a few, well, he can be 
quite influential (hard to say no to a friend that has always been there 
for you), especially if the bars closed way to early (3 AM?). Anyway, I 
didn't type that (John did, and he probably thought it would be absurdly 
funny too, who knows). 

[toc] | [prev] | [next] | [standalone]


#7915

From"MikeP" <mp011011@some.org>
Date2011-07-17 03:04 -0500
Message-ID<ivu52c$vf$2@dont-email.me>
In reply to#7910
Robert Wessel wrote:

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

[toc] | [prev] | [next] | [standalone]


#8082

FromNick Keighley <nick_keighley_nospam@hotmail.com>
Date2011-07-22 00:32 -0700
Message-ID<5f696d02-9faa-4d74-91a6-42fd7d6211aa@c41g2000yqm.googlegroups.com>
In reply to#7905
On Jul 17, 6:07 am, "MikeP" <mp011...@some.org> wrote:
> Robert Wessel wrote:
> > On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <mp011...@some.org> 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.

define-type bool
    bool is-element-of {symbol-true, symbol-false}
    abbrev symbol-true=T symbol-false=F  -- just within this
definition

    operators
        and:    T and T = T, T and F = F,  F and T = F,  F and F = F
        ...

I believe bools can be defined in terms of lattices (the hour I spent
on that comp sci lecture I will never get back)

[toc] | [prev] | [next] | [standalone]


#8083

FromNick Keighley <nick_keighley_nospam@hotmail.com>
Date2011-07-22 00:41 -0700
Message-ID<aa772a94-32da-4eb9-819b-e09e2c71fb7f@bl1g2000vbb.googlegroups.com>
In reply to#7905
On Jul 17, 6:07 am, "MikeP" <mp011...@some.org> wrote:
> Robert Wessel wrote:
> > On Sat, 16 Jul 2011 05:33:22 -0500, "MikeP" <mp011...@some.org> 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.

define-type bool
    bool is-element-of {symbol-true, symbol-false}
    abbrev symbol-true=T symbol-false=F  -- just within this
definition

    operators
        and:    T and T = T, T and F = F,  F and T = F,  F and F = F
        ...

[toc] | [prev] | [next] | [standalone]


#7923

FromJuha Nieminen <nospam@thanks.invalid>
Date2011-07-17 13:50 +0000
Message-ID<4e22e8ac$0$2823$7b1e8fa0@news.nbl.fi>
In reply to#7870
MikeP <mp011011@some.org> 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?

[toc] | [prev] | [next] | [standalone]


#7933

From"MikeP" <mp011011@some.org>
Date2011-07-18 06:50 -0500
Message-ID<j016l9$84h$1@dont-email.me>
In reply to#7923
Juha Nieminen wrote:
> MikeP <mp011011@some.org> 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?'

So the answer would then be adolescent stupidity\ 

[toc] | [prev] | [next] | [standalone]


#8007

FromJames Kanze <james.kanze@gmail.com>
Date2011-07-20 13:06 -0700
Message-ID<db4cc069-8907-43bd-9310-d74478fa6a0a@e18g2000vbx.googlegroups.com>
In reply to#7933
On Jul 18, 12:50 pm, "MikeP" <mp011...@some.org> wrote:
> Juha Nieminen wrote:
> > MikeP <mp011...@some.org> 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?'

> So the answer would then be adolescent stupidity\

Or enough maturity to recognize that not all machines are PC's.

--
James Kanze

[toc] | [prev] | [next] | [standalone]


#8036

FromPawel Dziepak <pdziepak@quarnos.org>
Date2011-07-21 12:59 +0000
Message-ID<j097rl$qcg$1@dont-email.me>
In reply to#7923
Juha Nieminen wrote:

> MikeP <mp011011@some.org> 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?

In fact, the size of char is also implementation defined. sizeof(char) == 
1, but there is no guarantee that it means that char is 8 bit wide. What 
the standard tells about char is that it is large enough to store 
"implementation's basic character set". There is nothing that forbids, 
e.g., 9-bit chars.

-- 
Pawel Dziepak

[toc] | [prev] | [next] | [standalone]


#8038

FromJames Kanze <james.kanze@gmail.com>
Date2011-07-21 07:11 -0700
Message-ID<1a320ae6-27c2-45ad-98d6-ec65c81915be@g12g2000yqd.googlegroups.com>
In reply to#8036
On Jul 21, 1:59 pm, Pawel Dziepak <pdzie...@quarnos.org> wrote:
> Juha Nieminen wrote:
> > MikeP <mp011...@some.org> 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?

> In fact, the size of char is also implementation defined. sizeof(char) ==
> 1, but there is no guarantee that it means that char is 8 bit wide. What
> the standard tells about char is that it is large enough to store
> "implementation's basic character set". There is nothing that forbids,
> e.g., 9-bit chars.

There is, in fact, at least one modern implementation which uses
9 bit chars.  There are also, from what I've been told, a couple
which use 32 bit chars.

--
James Kanze

[toc] | [prev] | [next] | [standalone]


#8069

From"JBarleycorn" <jbnh2o@newsnet.org>
Date2011-07-21 19:21 -0500
Message-ID<j0afqg$1fg$1@dont-email.me>
In reply to#8038
James Kanze wrote:
> On Jul 21, 1:59 pm, Pawel Dziepak <pdzie...@quarnos.org> wrote:
>> Juha Nieminen wrote:
>>> MikeP <mp011...@some.org> 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?
>
>> In fact, the size of char is also implementation defined.
>> sizeof(char) == 1, but there is no guarantee that it means that char
>> is 8 bit wide. What the standard tells about char is that it is
>> large enough to store "implementation's basic character set". There
>> is nothing that forbids, e.g., 9-bit chars.
>
> There is, in fact, at least one modern implementation which uses
> 9 bit chars.  There are also, from what I've been told, a couple
> which use 32 bit chars.

Anything that implements char as anything other than 8-bits is an exotic, 
IMO, and therefore does not deserve to taint all other code for its 
existence. Special circumstances require special handling. Code for the 
common case, to some defined "common", and not for the exceptional case. 
Imagine telling your client that you didn't take advantage of the fact 
that most platforms define char as 8-bits and then telling them the 
statistics and applicability to their needs of those exotic platforms. 
They would run you out of town on a rail.. or *should*! 

[toc] | [prev] | [next] | [standalone]


#8103

FromJames Kanze <james.kanze@gmail.com>
Date2011-07-22 12:28 -0700
Message-ID<e1a782e3-6396-4159-bf6d-65bf3b57a373@d32g2000yqa.googlegroups.com>
In reply to#8069
On Jul 22, 1:21 am, "JBarleycorn" <jbn...@newsnet.org> wrote:
> James Kanze wrote:

    [...]
> Anything that implements char as anything other than 8-bits is an exotic,

I tend to agree, but I've heard that 32 bit char is fairly
common on embedded platforms.  (But I've no concrete knowledge
of this---when I was working on embedded platforms, they were
still all 8 bit processors.)

> IMO, and therefore does not deserve to taint all other code for its
> existence.

It doesn't taint the code.  I suspect that well over 90% of the
code I've written would run on a 36 ones complement processor
(Unisys 2200 mainframe) without any changes.  Not because I
wrote it with the intent of being portable to such a platform,
but because I wrote it cleanly, in the philosophy of C/C++ (as
explained by Kernighan and Richie).  A lot of my modern code
will not run on a 16 bit processor, because it assumes that an
int is at least 32 bits (or at least considerably more than 16
bits); this seems a reasonable compromize for the environments I
currently work in.  But the size of bool has never been an
issue.

> Special circumstances require special handling. Code for the
> common case, to some defined "common", and not for the exceptional case.
> Imagine telling your client that you didn't take advantage of the fact
> that most platforms define char as 8-bits and then telling them the
> statistics and applicability to their needs of those exotic platforms.
> They would run you out of town on a rail.. or *should*!

But the size of an int or a char makes no difference in most of
the code, as long as it is big enough to hold all of the values
I need.

--
James Kanze

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

Back to top | Article view | comp.lang.c++


csiph-web