Skip to content

Conversation

adsr
Copy link
Contributor

@adsr adsr commented Oct 14, 2022

Useful for when integer overflow is desired instead of becoming a float.

Synopsis:

php > var_dump(PHP_INT_MAX + 1);
float(9.223372036854776E+18)
php > var_dump(intadd(PHP_INT_MAX, 1));
int(-9223372036854775808)

Can write an RFC if desired.

(Requesting hacktoberfest-accepted label for Hacktoberfest cred.)

@juan-morales
Copy link
Contributor

Hello @adsr

Can write an RFC if desired.

is not desired, in your case ... is a must I would say.

Copy link
Member

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@juan-morales
Copy link
Contributor

@bwoebi Hello.

I Am curious about your approval on the PR what Does it mean?

This is just to know More about the process in PHP contribution.

Z_PARAM_LONG(addend2)
ZEND_PARSE_PARAMETERS_END();

RETURN_LONG(addend1 + addend2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed integer overflow is undefined, this should be converted to unsigned (and back).

@cmb69
Copy link
Member

cmb69 commented Oct 14, 2022

IMO, this needs at least discussion on the internals mailing list. Personally, I'm not in favor of this, unless we'd implement full support for all operators (e.g. multiplication). And even then, I almost never find overflow behavior reasonable, and would rather prefer an exception (or way better, bigint support).

@juan-morales
Copy link
Contributor

I agree with @cmb69

@devnexen
Copy link
Member

Let's see what people think on the list but that s a no for me, usually I appreciate new ideas, but I m not liking this one.

@krakjoe
Copy link
Member

krakjoe commented Aug 31, 2025

I'm closing this because I think it's misleading to leave it open, nobody can act on this without an RFC and the RFC never materialized in nearly three years.

If I'm wrong and there was substantial discussion that resolved the things raised here, or you intend to write a formal RFC, feel free to re-open targeting the current master branch (there are conflicts).

@krakjoe krakjoe closed this Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants