[Mono-devel-list] Re: Abcremoval

Willibald Krenn Willibald.Krenn at gmx.at
Tue Feb 1 10:23:55 EST 2005


Massimiliano Mantione schrieb:
> On Tue, 2005-02-01 at 14:36, Willibald Krenn wrote:
> 
>>  -> Simplify example by making 'pos' unsigned int and possibly 
>>introducing an overload Char indexer. (Or do some other trick so abcrem 
>>can be sure that the index will never be treated as signed.)
> 
> 
> Yes, the fact that the index could be signed is an issue, but in
> any case for now both the index and the string *must* be local
> variables of the method, so that SSA can track their assignments.

Ok, this is the stopper then (for mentioned example).


> Maybe I'm just picky, but it seems to me that the check is performed
> on the index before the shift.
> So, for strings with a length in the range 0x40000000-0x7fffffff
> any index in that range would be valid when checked, but become
> negative just after the shift (defying the bounds check).
> Is this true?

No, AFAICT the index is treated as unsigned int32 (minus MSB):
shl    %eax	/* multiply by 2; clears top 32 bits on AMD64 IIRC;*/
/*no signed widening here*/
add    %rcx,%rax /*rcx is pointer to string; rax is index by two */
movzwq 0x14(%rax),%r14 /*copy*/

IOW: There is no such thing as a negative index for string access.

Thanks,
    Willi




More information about the Mono-devel-list mailing list