Hi Anatol,

I don't see any problem adding ZEND_LONG_INT_OVF and similar macros into
7.0.

Thanks. Dmitry.

On Mon, Aug 24, 2015 at 5:15 PM, Anatol Belski <anatol....@belski.net>
wrote:

> Hi Rowan,
>
> > -----Original Message-----
> > From: Rowan Collins [mailto:rowan.coll...@gmail.com]
> > Sent: Monday, August 24, 2015 12:29 AM
> > To: internals@lists.php.net
> > Subject: Re: [PHP-DEV] Overflow checks and integral vars comparison
> >
> > On 22/08/2015 02:38, Sherif Ramadan wrote:
> > > I see. So you're not actually doing overflow checks then? Because at
> > > the point you'd be checking this zend_long or size_t it could have
> > > already overflowed or wrapped. The subject may have misled me to
> > > understand differently.
> >
> > I think I understand the confusion: you are thinking of overflow as
> something
> > which happens *within* a type based on some operation (addition,
> > multiplication, etc).
> >
> > Anatol is talking about overflows which occur when casting *between*
> > types: a value of 2^33 can safely be passed around as a 64-bit integer,
> no
> > overflow has occurred; but attempting to cast it to a 32-bit integer will
> > immediately overflow the 32-bit integer.
> >
> > Since many PHP extensions are wrappers around libraries which may only
> deal in
> > 32-bit types, this cast is common, necessitating range checks like the
> ones
> > proposed.
> >
> Yep, that's the exact point. Not touching arithmetic operations as it is a
> complex thing. Even on 64-bit fe there are intrinsics for doing 128-bit
> math which could be used. ASM could be helpful ofc, however it needs much
> care, fe even within GCC versions. So it is big and should be another story
> :)
>
> Overflows in the cast can happen when passing args, comparing variables of
> different type or signess, or even with the numeric constants. Hence that
> cast (zend_long)INT_MAX for example. At the end - it's still an
> overflow/underflow issue. I'm going for an RFC with this to target 7.1.
>
> Thanks.
>
> anatol
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to