Re: Request for warnings on implicit bool to int conversions

2012-03-28 Thread Michael Witten
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

Re: Request for warnings on implicit bool to int conversions

2012-03-28 Thread Franz Sirl
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

Re: Request for warnings on implicit bool to int conversions

2012-03-27 Thread Russ Allbery
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

Re: Request for warnings on implicit bool to int conversions

2012-03-27 Thread Russ Allbery
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

Re: Request for warnings on implicit bool to int conversions

2012-03-27 Thread Gabriel Dos Reis
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

Re: Request for warnings on implicit bool to int conversions

2012-03-27 Thread Russ Allbery
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

Re: Request for warnings on implicit bool to int conversions

2012-03-27 Thread Gabriel Dos Reis
> 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

Re: Request for warnings on implicit bool to int conversions

2012-03-27 Thread Paolo Carlini
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