On Nov 13, 2008, at 7:41 PM, Ted Kremenek wrote:
>> Is this the rule:
>>  - if the bitwidth of E2 is the same as the pointer, do the  
>> arithmetic.
>>  - if the bitwidth of E2 is different from the pointer, trunc or  
>> ext it to the same width of the pointer. Signed-ness affects the  
>> ext operation. Then do the arithmetic.
>
> I'm not certain.  Note that the 'long long' value 'k' was not  
> truncated.  Is this a Sema bug, or is this the correct behavior?   
> For this target LongLongWidth is 64, the bit width for 'int' is 32,  
> and the bit width for a pointer is (I believe) 32 bits as well.

This is correct for Sema, and as others pointed out, codegen does the  
truncation.  Overflow is undefined for pointers, so truncating the  
index to the size of the pointer is safe to do,  Zhongxing's rules  
above should work great!

-Chris
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to