Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8025
| From | "JBarleycorn" <jbnh2o@newsnet.org> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Size of bool unspecified: why? |
| Date | 2011-07-21 02:56 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <j08m2h$ch6$1@dont-email.me> (permalink) |
| References | (4 earlier) <98ou27FaegU3@mid.individual.net> <j07s3r$hk6$1@dont-email.me> <98pi8pFroiU1@mid.individual.net> <j089to$j9f$1@dont-email.me> <98pp2qFroiU2@mid.individual.net> |
"Ian Collins" <ian-news@hotmail.com> wrote in message news:98pp2qFroiU2@mid.individual.net... > On 07/21/11 04:28 PM, JBarleycorn wrote: >> "Ian Collins"<ian-news@hotmail.com> wrote in message >> news:98pi8pFroiU1@mid.individual.net... >>> On 07/21/11 12:32 PM, JBarleycorn wrote: >>>> "Ian Collins"<ian-news@hotmail.com> wrote in message >>>> news:98ou27FaegU3@mid.individual.net... >>>>> On 07/21/11 08:46 AM, JBarleycorn wrote: >>>>>> James Kanze wrote: > >>>>>>> First, is size of bool unspecified? Or just implementation >>>>>>> defined? >>>>>> >>>>>> Isn't that the same thing? >>>>> >>>>> Not in terms of the standard. Implementation defined things have >>>>> to >>>>> be >>>>> defined by the implementation. >>>> >>>> Why is "unspecified" necessary? Does anyone think that not >>>> specifying >>>> the >>>> size of a bool is a good thing? >>>> >>>> How can bools be used in structs if every implementation can define >>>> it >>>> differently? >>> >>> The same way ints can be used in structs when every implementation >>> can >>> define them differently. >> >> You can used fixed-width integers but there is no complementary bool >> type. bool is unusable in structs in many instances then. >> Serialization >> is not a panacea, it's tedium. > > The only places where sizeof(bool) matters it will be defined. The need for fixed-width integers has been proven and therefore they are in the standard, but then they forget the past and create a new type and don't consider that width matters for that type. Either that or they considered it not useful in the situations where the fixed-width integers are a boon. They should have specified a width, as the alternative of having multiple booleans of different widths isn't practical I believe. A header of an application program can check if fixed-width integer types are what the program expects and if not, then adjustments can be made, but with bool, whaddaya going to do if the size of bool doesn't meet the app's expectations? Use an integer of the right size? What's the point of having a bool at all then if it is likely that some compiler or version of it doesn't support the needed type? It seems that any case you make for the width of bool being OK unspecified, refutes the need for fixed-width integer types, and vice-versa. Where is the consistency? > >>>>>>> A bool is required to be addressable; sizeof(bool) is also >>>>>>> required to return an integral value. So a bool can't be >>>>>>> smaller than a char. On a byte addressable machine, there's >>>>>>> also no reason to make them bigger, >>>>>> >>>>>> Efficiency? >>>>> >>>>> Maybe, but efficiency isn't only dependent on size. If it were, >>>>> we'd >>>>> be using 64 bit ints on 64 bit machines. >>>>> >>>> >>>> I meant efficient in time, not space. Are not 64-bit ints indeed >>>> more >>>> efficient (in time) than 32-bit ints, say on x86 vs. x64? Anyone >>>> have >>>> a >>>> good simple test for this? Probably at least 3 things need to be >>>> eval'd: >>>> argument passing performance, return value performance, arithmetic >>>> performance. I can compare the 8-bit bool vs. a 32-bit int on my >>>> machine, >>>> but I don't have a 64-bit machine. >>> >>> Efficient in time can be the same as efficient in space. The most >>> valuable resource on modern CPUs is the cache, the bigger a data >>> type, >>> the quicker the cache overflows. That's why performance of some >>> applications is better built 64 bit and worse for others. >>> >> >> I guess I'll just have to profile it myself and see if there is >> significant difference. > > Define "it". > > What part of "performance of some applications is better built 64 bit > and worse for others" didn't you get? > I don't think it is as nebulous as you make it seem. I gave 3 instances: arguments, return vals and arithmetic. I don't believe that *no* conclusions can be drawn from analysis of those instances in regards to integer sizes. Yes, the assumptions (platforms, compilers...) will have to be stated, but that's how scientific study works: you study some finite subset of the universe to gain insight. That insight, as a practical matter, is what I was looking for. If I was building a language from scratch and choosing a size for the boolean type, the performance of that type, as a practical matter, would or might factor into the design of that type. Similarly, if I was introducing a boolean type into a language that does not yet have one, I would consider the same issue.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web