Skip to content

ext/bcmath: Use const qualifiers appropriately #18284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2025

Conversation

SakiTakamachi
Copy link
Member

No description provided.

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

I'm okay with this, please see my remark to check if this is what you intended.

@@ -1019,7 +1019,7 @@ static void bcmath_number_register_class(void)
}

static zend_always_inline void bcmath_number_add_internal(
bc_num n1, bc_num n2, bc_num *ret,
const bc_num n1, const bc_num n2, bc_num *ret,
Copy link
Member

Choose a reason for hiding this comment

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

Note that bc_num is defined as follows: typedef struct bc_struct *bc_num;
Unfortunately, const bc_num won't do what you probably think it does: it doesn't make the pointer const, it just makes the binding of the variable const. If it was written like bc_struct *n1 then n1 would be a const pointer if you added const before it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@nielsdos

Ahhhh, indeed.....

Do you think it would be redundant to define a new type just for this?

Copy link
Member

Choose a reason for hiding this comment

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

Feels a bit silly

@SakiTakamachi
Copy link
Member Author

@nielsdos

bc_num has been restored, I merge it later!

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

Still OK

@SakiTakamachi SakiTakamachi merged commit c927d24 into php:master Apr 11, 2025
9 checks passed
@SakiTakamachi SakiTakamachi deleted the bcmath/add_const branch April 11, 2025 03:39
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.

2 participants