This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH RFA: Change variable to bool


"Joseph S. Myers" <joseph@codesourcery.com> writes:

> On Tue, 16 Jun 2009, Ian Lance Taylor wrote:
>
>> In the function grokdeclarator in c-decl.c the local variable
>> size_varies has type int, but is effectively treated as a bool.  In
>> particular, it is used in statements like
>>   this_size_varies = size_varies = 1;
>> where this_size_varies has type bool.  This is OK in C but the C++
>> frontend gives a warning about an assignment used as a truth value
>> without parentheses.  This patch avoids the issue by changing the type
>> of size_varies, which seems like the right thing to do anyhow.
>> 
>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  This patch
>> requires the approval of a C frontend maintainer or a global
>> maintainer.  OK for mainline?
>
> This is OK, but the difference in warnings should be filed as a PR 
> (probably C should warn here).

I looked a little deeper, and actually the C frontend has this warning
too.  The difference is that when compiling gcc with C, the type "bool"
is equivalent to "unsigned char".  When compiling with C++, it remains,
of course, "bool".

If system.h were changed to define "bool" as "_Bool" when compiling C,
the same warning would have appeared.

Patch committed.  Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]