Re: [bool wrapping] Request for warnings on implicit bool to int conversions

2012-03-29 Thread mathog
On 29-Mar-2012 03:20, David Brown wrote: On 29/03/2012 00:52, mathog wrote: A better solution for the aesthetics would have been (it is a bit late now) to implement the missing unary negation operator: !!b; //T->F, F->T You can't do that, because "!!" is already a useful operator on integ

Re: [bool wrapping] Request for warnings on implicit bool to int conversions

2012-03-29 Thread David Brown
On 29/03/2012 00:52, mathog wrote: On 28-Mar-2012 15:20, Michael Witten wrote: However, it seems to me that toggling the value with the idiom: --b; is aesthetically preferable to the more elaborate: b = !b; Aesthetically, not logically. Neither of these makes the least bit of sense: one l

Re: [bool wrapping] Request for warnings on implicit bool to int conversions

2012-03-28 Thread mathog
On 28-Mar-2012 15:20, Michael Witten wrote: However, it seems to me that toggling the value with the idiom: --b; is aesthetically preferable to the more elaborate: b = !b; Aesthetically, not logically. Neither of these makes the least bit of sense: one less than False one less

Re: [bool wrapping] Request for warnings on implicit bool to int conversions

2012-03-28 Thread Michael Witten
On Wed, Mar 28, 2012 at 20:30, mathog wrote: > Since b-- is equivalent to [assigning] !b, > and b++ is equivalent to [assigning] 1, if > that action is intended, there is no reason > to use either the increment or decrement > operators on a bool. However, it seems to me that toggling the value w

Re: [bool wrapping] Request for warnings on implicit bool to int conversions

2012-03-28 Thread mathog
On 28-Mar-2012 12:18, Michael Witten wrote: Wow, that was thorough! The behavior of b++ vs. b-- was interesting, but is yet one more reason why the warning is needed. Since b-- is equivalent to !b, and b++ is equivalent to 1, if that action is intended, there is no reason to use either the i

Re: [bool wrapping] Request for warnings on implicit bool to int conversions

2012-03-28 Thread Michael Witten
On Tue, 27 Mar 2012 19:20:52 -0700, Russ Allbery wrote: > (For example, b++ could easily wrap, and unexpectedly fast > depending on the size of bool on a platform.) Actually, it would appear that a bool (or a _Bool) can't wrap on increment, but it CAN wrap on decrement (and strangely, when the op