This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [exception patch]: Throw bad alloc
Jason Merrill wrote:
>
> >>>>> Nathan Sidwell <nathan@codesourcery.com> writes:
> > + size_t diff = (size_t)((char *)p - &eh->alloc_buffer[0]);
>
> This should be ptrdiff_t.
Ah, I've just realized this is presuming a linear address space. Is that
valid? If not it should be coded as
if ((char *)p >= &eh->alloc_buffer[0]
&& (char *)p < &eh->alloc_buffer[EH_ALLOC_SIZE])
If a linear address space is ok, then setting diff to be ptrdiff_t will
make the conditional
if (diff >= 0 && diff < EH_ALLOC_SIZE)
which is the canonical way of writing this?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org