Skip to content

ext/intl: fix build with older ICU - #23539

Merged
devnexen merged 1 commit into
php:masterfrom
oerdnj:fix-build-with-old-ICU
Sep 2, 2026
Merged

ext/intl: fix build with older ICU#23539
devnexen merged 1 commit into
php:masterfrom
oerdnj:fix-build-with-old-ICU

Conversation

@oerdnj

@oerdnj oerdnj commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Covariant return types for clone() were only introduced in ICU 65; before that NumberFormat::clone() returns Format*, so cast the result explicitly in NumberFormatter_object_clone().

<unicode/numberrangeformatter.h> is a C++-only header, and older ICU does not wrap it in U_SHOW_CPLUSPLUS_API, so including it from php_intl.c breaks the C compile. Move it into the __cplusplus branch, next to the using declaration that needs it.

@oerdnj

oerdnj commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

I know that Debian Buster is long dead, but this is a simple change and will help with the packaging for older releases.

Comment thread ext/intl/formatter/formatter_class.cpp Outdated
@oerdnj
oerdnj force-pushed the fix-build-with-old-ICU branch from b0d735c to 4374f98 Compare September 2, 2026 12:04
@devnexen

devnexen commented Sep 2, 2026

Copy link
Copy Markdown
Member

Covariant return types for clone() were only introduced in ICU 64; before that NumberFormat::clone() returns Format*, so cast the result explicitly in NumberFormatter_object_clone().

Are you sure it s not ICU 65 (NumberFormat::clone() as virtual) ?

@devnexen devnexen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm static_cast is safe to use in this case.

@oerdnj

oerdnj commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Covariant return types for clone() were only introduced in ICU 64; before that NumberFormat::clone() returns Format*, so cast the result explicitly in NumberFormatter_object_clone().

Are you sure it s not ICU 65 (NumberFormat::clone() as virtual) ?

Debian Buster had 63.1-6+deb10u4 and Debian Bullseye had 67.1-7, so it some version of ICU between these two versions. But reading the changelog, I think you might be right: https://icu.unicode.org/download/65

I've amended the commit and the comment above and force pushed.

Covariant return types for clone() were only introduced in ICU 65;
before that NumberFormat::clone() returns Format*, so cast the result
explicitly in NumberFormatter_object_clone().

<unicode/numberrangeformatter.h> is a C++-only header, and older ICU
does not wrap it in U_SHOW_CPLUSPLUS_API, so including it from
php_intl.c breaks the C compile.  Move it into the __cplusplus branch,
next to the using declaration that needs it.
@oerdnj
oerdnj force-pushed the fix-build-with-old-ICU branch from 4374f98 to 7cee3e6 Compare September 2, 2026 13:16
@devnexen
devnexen merged commit 386a467 into php:master Sep 2, 2026
16 of 18 checks passed
@devnexen

devnexen commented Sep 2, 2026

Copy link
Copy Markdown
Member

Thanks !

@oerdnj
oerdnj deleted the fix-build-with-old-ICU branch September 2, 2026 14:27
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