Skip to content

Commit da72ac1

Browse files
committed
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.
1 parent 82e63a0 commit da72ac1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ PHP NEWS
4242
. pg_convert/pg_insert/pg_update/pg_delete ; regexes are now cached.
4343
(David Carlier)
4444

45+
- Random:
46+
. Fixed bug GH-15094 (php_random_default_engine() is not C++ conforming).
47+
(cmb)
48+
4549
- Standard:
4650
. Fix references in request_parse_body() options array. (nielsdos)
4751
. Add RoundingMode enum. (timwolla, saki)

ext/random/php_random.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ PHPAPI void *php_random_default_status(void);
167167

168168
static inline php_random_algo_with_state php_random_default_engine(void)
169169
{
170-
return (php_random_algo_with_state){
171-
.algo = php_random_default_algo(),
172-
.state = php_random_default_status(),
173-
};
170+
php_random_algo_with_state raws;
171+
raws.algo = php_random_default_algo();
172+
raws.state = php_random_default_status();
173+
return raws;
174174
}
175175

176176
PHPAPI zend_string *php_random_bin2hex_le(const void *ptr, const size_t len);

0 commit comments

Comments
 (0)