This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: More front end type mismatch problems
- From: Paul Schlie <schlie at comcast dot net>
- To: Diego Novillo <dnovillo at redhat dot com>,Andrew Pinski <pinskia at physics dot uc dot edu>,<gcc at gcc dot gnu dot org>,Richard Henderson <rth at redhat dot com>
- Date: Sat, 28 May 2005 01:02:49 -0400
- Subject: Re: More front end type mismatch problems
>> On Fri, May 27, 2005 at 02:45:14PM -0400, Andrew Pinski wrote:
>>> re:
>>> char *foo(char *p, char *q) {
>>> int x = (p !=0) + (q != 0);
>>> ...
>>> }
>>
>> Are you sure, the NE_EXPR does not have a type of INTEGER_TYPE?
>> This sounds like a missing fold_convert somewhere.
>>
> Ah, yes. I see what you mean now. The comparison was of type
> int but the evaluation was generating a _Bool value. My bad.
Especially for the purpose of VRP, why wouldn't it be most ideally
appropriate to define the result of a comparison to be a _Bool, as it's
constrained to the range of 0:1; and by "usual arithmetic conversion",
need only typically be promoted to a char rank integer (presuming _Bool
is not specified to be of greater rank than char), thereby most optimally:
int x = (int)((char)(_Bool)((*)p != (*)0) + (char)(_Bool)((*)q != (*)0))
it would seem?