Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Lowell Gilbert <lgusenet@be-well.ilk.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: c99 and the lack of warnings when int operations are applied to a bool |
| References | (8 earlier) <0.e11fb3f8deb5417cdcac.20120325210539BST.87aa34qwdo.fsf@bsb.me.uk> <447gy8309c.fsf@lowell-desk.lan> <0.c4a6b01205b5072abeb6.20120325221452BST.871uogqt6b.fsf@bsb.me.uk> <jkooqr$5e6$1@dont-email.me> <0.904f115261cdf6365d9b.20120326120504BST.87sjgvpqqn.fsf@bsb.me.uk> |
| Date | 2012-03-26 15:22 -0400 |
| Message-ID | <44k427i2v0.fsf@lowell-desk.lan> (permalink) |
Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > James Kuyper <jameskuyper@verizon.net> writes: > >> On 03/25/2012 05:14 PM, Ben Bacarisse wrote: >>> Lowell Gilbert <lgusenet@be-well.ilk.org> writes: >>> >>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes: >>>> >>>>> "BartC" <bc@freeuk.com> writes: >>>>> >>>>>> (What *would* be useful would be int*bool, bool*double, etc. So A*bool is >>>>>> either A, or zero. But a simple cast to int will achieve the same.) >>>>> >>>>> The "would" suggests that this is not currently possible, but it is (and >>>>> no casts are needed). >>>> >>>> It's possible if you're sure the bool only holds zero or one. >>>> >>>> In practice, it is frequently safer to use >>>> (bool ? A : 0) >>>> which is only necessary because the bool does (in fact) typically have >>>> the semantics of a larger type of integer >>> >>> Are we talking about the same thing? C's standard bool (a macro that >>> expands to _Bool) does not have the semantics of a larger integer type. >> >> It implicitly converts to int in most contexts, including all of the >> contexts that have been the subject of this thread. I think that's what >> Lowell was referring to. The only specifically boolean semantics it has >> is on conversion to _Bool. > > This: "it's possible if you're sure the bool only holds zero or one" and > "bool [has] the semantics of a larger type of integer" only "typically" > rather than always, suggests that is not what was meant. > > I think he was talking about a situation where you don't know whether > you have C99 bools or a pre-C99 implementation of a bool type and, in > that context, he makes a good point, but that's not what Jacob was > talking about and this not what I was commenting on. Yes. Apparently my brain has the capitalization wrong for the two types, so I thought we were talking about different types. Sorry for the (my) confusion. -- Lowell Gilbert, embedded/networking software engineer http://be-well.ilk.org/~lowell/
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
c99 and the lack of warnings when int operations are applied to a bool mathog <dmathog@gmail.com> - 2012-03-23 08:40 -0700
Re: c99 and the lack of warnings when int operations are applied to a bool James Kuyper <jameskuyper@verizon.net> - 2012-03-23 12:07 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool jacob navia <jacob@spamsink.net> - 2012-03-23 21:45 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Robert Wessel <robertwessel2@yahoo.com> - 2012-03-23 17:17 -0500
Re: c99 and the lack of warnings when int operations are applied to a bool jacob navia <jacob@spamsink.net> - 2012-03-23 23:29 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Ian Collins <ian-news@hotmail.com> - 2012-03-24 11:48 +1300
Re: c99 and the lack of warnings when int operations are applied to a bool jacob navia <jacob@spamsink.net> - 2012-03-24 23:47 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Willem <willem@toad.stack.nl> - 2012-03-25 09:05 +0000
Re: c99 and the lack of warnings when int operations are applied to a bool "BartC" <bc@freeuk.com> - 2012-03-25 11:30 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-25 21:05 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Lowell Gilbert <lgusenet@be-well.ilk.org> - 2012-03-25 16:15 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-25 22:14 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool James Kuyper <jameskuyper@verizon.net> - 2012-03-25 23:46 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-26 12:05 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Lowell Gilbert <lgusenet@be-well.ilk.org> - 2012-03-26 15:22 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool Gareth Owen <gwowen@gmail.com> - 2012-03-25 11:44 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-25 13:06 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-27 11:12 -0700
Re: c99 and the lack of warnings when int operations are applied to a bool Robert Wessel <robertwessel2@yahoo.com> - 2012-03-24 01:15 -0500
Re: c99 and the lack of warnings when int operations are applied to a bool jacob navia <jacob@spamsink.net> - 2012-03-24 23:29 +0100
Re: c99 and the lack of warnings when int operations are applied to a bool mathog <dmathog@gmail.com> - 2012-03-27 09:53 -0700
Re: c99 and the lack of warnings when int operations are applied to a bool Keith Thompson <kst-u@mib.org> - 2012-03-27 11:07 -0700
Re: c99 and the lack of warnings when int operations are applied to a bool James Kuyper <jameskuyper@verizon.net> - 2012-03-27 14:16 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-04-26 07:57 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool jacob navia <jacob@spamsink.net> - 2012-04-26 14:08 +0200
Re: c99 and the lack of warnings when int operations are applied to a bool James Kuyper <jameskuyper@verizon.net> - 2012-04-26 09:09 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-04-26 21:29 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool James Kuyper <jameskuyper@verizon.net> - 2012-04-26 21:58 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-04-26 22:32 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool James Kuyper <jameskuyper@verizon.net> - 2012-04-27 06:31 -0400
Re: c99 and the lack of warnings when int operations are applied to a bool ImpalerCore <jadill33@gmail.com> - 2012-04-27 08:31 -0700
csiph-web