egcs-20000306 ICE in `size_binop', at fold-const.c:1873

Mark Mitchell
Fri Mar 17 08:43:00 GMT 2000

>>>>> "Richard" == Richard Kenner <> writes:

    Richard> As to the issue of negative offsets, I was thinking about
    Richard> that and now feel that offsets, in most languages, are
    Richard> always positive.  If they can be negative, the language
    Richard> should use a signed type for sizetype.  On the other
    Richard> hand, there's no problem systematically using a signed
    Richard> variant of sizetype for offsets.

I think having sizetype not be the same type as `size_t' is pretty
confusing in C.  It seems to me that offsets should have type
`ptrdiff_t', and sizes should have type `size_t'; I guess those are
spelled `ssizetype' and `sizetype'.  But, then, it should be allowed
to add a `ssizetype' to a `sizetype', just as in C you can add a
`ptrdiff_t' to a `size_t'.

I don't know about "most languages", but offsets can definitely be
negative in C and C++.  Any time that `p' and `q' are two pointers, 
`p - q' is a signed quantity, and that's well-defined, as long as `p'
and `q' point into the same array.

Mark Mitchell         
CodeSourcery, LLC     

More information about the Gcc-patches mailing list