From da72ac11f6a0344ba028d88c6b5662d865a8257c Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 25 Jul 2024 00:26:28 +0200 Subject: [PATCH] Fix GH-15094: php_random_default_engine() is not C++ conforming Using compound literals is conforming to C99 (and up), but not with any C++ standard. Since the code is in a public header, it might be used by C++ extensions. Unfortunately, we cannot even used designated initializers, because these are a C++20 feature, so we stick with classic C/C++ code. Closes GH-15100. --- NEWS | 4 ++++ ext/random/php_random.h | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 01bcee1ebb3..fb1fa2b793f 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,10 @@ PHP NEWS . pg_convert/pg_insert/pg_update/pg_delete ; regexes are now cached. (David Carlier) +- Random: + . Fixed bug GH-15094 (php_random_default_engine() is not C++ conforming). + (cmb) + - Standard: . Fix references in request_parse_body() options array. (nielsdos) . Add RoundingMode enum. (timwolla, saki) diff --git a/ext/random/php_random.h b/ext/random/php_random.h index e4aa3212667..4c6ce344f6e 100644 --- a/ext/random/php_random.h +++ b/ext/random/php_random.h @@ -167,10 +167,10 @@ PHPAPI void *php_random_default_status(void); static inline php_random_algo_with_state php_random_default_engine(void) { - return (php_random_algo_with_state){ - .algo = php_random_default_algo(), - .state = php_random_default_status(), - }; + php_random_algo_with_state raws; + raws.algo = php_random_default_algo(); + raws.state = php_random_default_status(); + return raws; } PHPAPI zend_string *php_random_bin2hex_le(const void *ptr, const size_t len);