Skip to content

php_random_default_engine() is not C++ conforming #15094

Description

@cmb69

Description

While trying to build sqlsrv 5.12.0 against PHP 8.4.0alpha2, I've noticed

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(),
};
}

While designated initializers are a C99 feature, they are only supported as of C++20, and that appears to stretch compiler support a bit too far.

Even worse, apparently the type cast isn't supported by MSVC (and maybe others) at all.

Replacing that function definition with the following works smoothly:

static inline php_random_algo_with_state php_random_default_engine(void)
{
	php_random_algo_with_state raws;
	raws.algo = php_random_default_algo();
	raws.state = php_random_default_status();
	return raws;
}

Maybe there is a better solution.

PHP Version

PHP 8.4

Operating System

Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions