Skip to content

strtok is not comptime #13148

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

Closed
wants to merge 1 commit into from
Closed

strtok is not comptime #13148

wants to merge 1 commit into from

Conversation

iluuu1994
Copy link
Member

Fixes GH-13145

GH-13145: strtok() misoptimization
--FILE--
<?php
$tok = strtok("This is\tan example\nstring", " \n\t");
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't the strtok function impl. be fixed instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

strtok() is stateful, the call cannot be skipped.

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.

LGTM, I suspected the same thing when I saw the issue and planned to do the same modification.

shouldn't the strtok function impl. be fixed instead?

Besides the statefulness, I think actually that comptime eval of this would be rare, it's not something that I expect to have constant inputs in normal applications even after constant propagation.

@iluuu1994
Copy link
Member Author

I think actually that comptime eval of this would be rare

I agree. The fact that this hasn't been reported before makes it pretty evident.

@iluuu1994 iluuu1994 closed this in ed64949 Jan 14, 2024
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.

3 participants