This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: egcs-20000306 ICE in `size_binop', at fold-const.c:1873
- To: kenner at vlsi1 dot ultra dot nyu dot edu
- Subject: Re: egcs-20000306 ICE in `size_binop', at fold-const.c:1873
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Fri, 17 Mar 2000 08:50:41 -0800
- Cc: gcc-patches at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <10003161812.AA02380@vlsi1.ultra.nyu.edu>
>>>>> "Richard" == Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 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 mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com