This is the mail archive of the gcc@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: 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?




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