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
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
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
On Wed, Mar 28, 2012 at 20:30, David Mathog wrote:
> ...
>
>> gcc -std=c99 -pedantic -Wall -O0 -fdump-tree-gimple d.c
>
>
> That's a trick worth knowing. Thanks!
> Ran that on a test program and in every case but one there was an implicit
>
> (int) b
>
> on sections of code which I though shoul
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
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
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
Am 2012-03-28 00:43, schrieb mathog:
The C99 bool data type, and the similar type in C++, currently (v 4.5.2)
do not generate
warnings for any of these sorts of operations:
bool b;
b = 3;
b++;
b += 2;
if(b == 3)
The last one is PR 44077.
Franz
Russ Allbery writes:
> Yeah. But I suspect it was a mistaken statement. The subject line from
> the referenced comp.lang.c thread was:
> c99 and the lack of warnings when int operations are applied to a bool
> which I think is best caught by the conversion *to* bool when the result
> is s
Gabriel Dos Reis writes:
> I can easily see why an implicit conversion from int to bool might cause
> a problem, even if that is what the language standard mandates -- just
> look at the most common misuses of strcmp. But, that is not what the
> proposer requested, which got me scratching my hea
On Tue, Mar 27, 2012 at 9:20 PM, Russ Allbery wrote:
> Gabriel Dos Reis writes:
>
>> I am trying to understand what the real issue is here. Do you want
>> -Wimplicit-char-to-int to? -Wimplicit-short-to-int? If not, why?
>> where to stop?
>
> I think it's more about conversion *to* bool than fr
Gabriel Dos Reis writes:
> I am trying to understand what the real issue is here. Do you want
> -Wimplicit-char-to-int to? -Wimplicit-short-to-int? If not, why?
> where to stop?
I think it's more about conversion *to* bool than from bool, and it
catches places where code has been partly conve
> Hi,
>>
>> It would be nice if there was a
>>
>> -Wimplicit_bool
>>
>> that was enabled in -Wall which complained about these sorts of
>> operations. In particular
>> it would warn any time a bool was implicitly promoted to an int.
>
I am trying to understand what the real issue is here. Do yo
Hi,
It would be nice if there was a
-Wimplicit_bool
that was enabled in -Wall which complained about these sorts of
operations. In particular
it would warn any time a bool was implicitly promoted to an int.
first blush your message should be a Bugzilla PR, this way the request
doesn't ris
The C99 bool data type, and the similar type in C++, currently (v
4.5.2) do not generate
warnings for any of these sorts of operations:
bool b;
b = 3;
b++;
b += 2;
if(b == 3)
etc.
This can lead to a lot of hidden mischief because a variable declared
far away may look like
an intege
15 matches
Mail list logo