Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jacob navia <jacob@spamsink.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: c99 and the lack of warnings when int operations are applied to a bool |
| Date | 2012-03-24 23:29 +0100 |
| Organization | lccwin |
| Message-ID | <jklhso$920$1@speranza.aioe.org> (permalink) |
| References | <jki5iu$jea$1@dont-email.me> <jkinde$or2$1@speranza.aioe.org> <2btpm7tmttqo12hmj37jhj0db4vobf07i9@4ax.com> <jkitfb$80v$1@speranza.aioe.org> <5voqm71rtjkb5elbqp12ue0d5eo4fgm38v@4ax.com> |
Le 24/03/12 07:15, Robert Wessel a écrit : > On Fri, 23 Mar 2012 23:29:03 +0100, jacob navia<jacob@spamsink.net> > wrote: > >> Le 23/03/12 23:17, Robert Wessel a écrit : >>> Yet the language has always allowed the results of logical or >>> relational operators to be used arithmetically. How do you define a >>> rule that continues to allow that but disallows the use of _Bools? >> >> The rule could be simply: >> >> Only boolean operations are allowed with bools: or, and, xor, not. If >> you want to do arithmetic with bools you store that into an int (or >> long double or whatever) and then you go on from there. >> >> Or you make a cast. > > > So you're suggesting that: > > d += (b!=c); /* works*/ > > but: > > bool a = (b!=c); d+= a; /* doesn't work */ If d is an int, the integer is being modified, not the boolean, so it is perfectly OK. But if you write bool b=0; b += 5; the boolean is being modified, that should be off limits or should give you a warning. By the way, the lcc-win warns if you write char m = 259; or short f = 966776655; Since any addition to a bool is mostly nonsense, it would be OK to warn about it.
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