Skip to content

Fix compile warnings under GCC 15.2.1#21320

Open
ndossche wants to merge 1 commit intophp:PHP-8.4from
ndossche:fix-compile-warnings
Open

Fix compile warnings under GCC 15.2.1#21320
ndossche wants to merge 1 commit intophp:PHP-8.4from
ndossche:fix-compile-warnings

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Mar 1, 2026

The compiler now infers constness through string functions. Adhere to that.
It also now warns about using multiplications in conditions.

The compiler now infers constness through string functions.
Adhere to that.
It also now warns about using multiplications in conditions.
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

We usually get reports for stable branches when new compiler versions become generally available, should be backport immediately or wait until that happens?


while (ptr && *ptr) {
end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
end = (char *) strchr(ptr, DEFAULT_DIR_SEPARATOR);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this cast, why is it necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

ptr is a const char * but end is a char *.
end cannot be made const because it is written to on line 1780. At that point, ptr actually isn't pointing to a constant character buffer anymore.
I didn't want to do too many changes because to fix this nicely we'd need to split the ptr variable.

Copy link
Member

@iluuu1994 iluuu1994 Mar 1, 2026

Choose a reason for hiding this comment

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

Oh ok, so the return type of strchr is now effectively const-generic. Right, it does seem like it would be best to split the vars. I'd prefer that, at least for master.

@ndossche
Copy link
Member Author

ndossche commented Mar 1, 2026

We usually get reports for stable branches when new compiler versions become generally available, should be backport immediately or wait until that happens?

This is the compiler that has been shipping for a few weeks now on Arch/Manjaro. So I'd say we go ahead with doing it directly in 8.4.

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