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.
This commit is contained in:
Christoph M. Becker 2024-07-25 00:26:28 +02:00
parent 82e63a06e2
commit da72ac11f6
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
2 changed files with 8 additions and 4 deletions

4
NEWS
View File

@ -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)

View File

@ -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);