Skip to content

Zend/zend_variables: use C99 designated initializers #10655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Zend/zend_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ static void ZEND_FASTCALL zend_empty_destroy(zend_reference *ref);
typedef void (ZEND_FASTCALL *zend_rc_dtor_func_t)(zend_refcounted *p);

static const zend_rc_dtor_func_t zend_rc_dtor_func[] = {
/* IS_UNDEF */ (zend_rc_dtor_func_t)zend_empty_destroy,
/* IS_NULL */ (zend_rc_dtor_func_t)zend_empty_destroy,
/* IS_FALSE */ (zend_rc_dtor_func_t)zend_empty_destroy,
/* IS_TRUE */ (zend_rc_dtor_func_t)zend_empty_destroy,
/* IS_LONG */ (zend_rc_dtor_func_t)zend_empty_destroy,
/* IS_DOUBLE */ (zend_rc_dtor_func_t)zend_empty_destroy,
/* IS_STRING */ (zend_rc_dtor_func_t)zend_string_destroy,
/* IS_ARRAY */ (zend_rc_dtor_func_t)zend_array_destroy,
/* IS_OBJECT */ (zend_rc_dtor_func_t)zend_objects_store_del,
/* IS_RESOURCE */ (zend_rc_dtor_func_t)zend_list_free,
/* IS_REFERENCE */ (zend_rc_dtor_func_t)zend_reference_destroy,
/* IS_CONSTANT_AST */ (zend_rc_dtor_func_t)zend_ast_ref_destroy
[IS_UNDEF] = (zend_rc_dtor_func_t)zend_empty_destroy,
Copy link
Member

Choose a reason for hiding this comment

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

well, if we are to use this C99 feature, would assignments such as
[IS_UNDEF...IS_DOUBLE] = work ?
otherwise, while the change itself is correct, as is I feel it does not real bring something to the table. What do you think ?

Copy link
Member

Choose a reason for hiding this comment

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

Isn't that range thing a GNU extension?

Copy link
Member

Choose a reason for hiding this comment

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

that s possible, maybe MSVC does not support it (would not surprise me).

Copy link
Member

Choose a reason for hiding this comment

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

I ll let @Girgias decide if it s worth merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't that range thing a GNU extension?

It is. https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
"To initialize a range of elements to the same value, write ‘[first ... last] = value’. This is a GNU extension."

It's tempting, but in this case it's not worth deviating from the standard.

[IS_NULL] = (zend_rc_dtor_func_t)zend_empty_destroy,
[IS_FALSE] = (zend_rc_dtor_func_t)zend_empty_destroy,
[IS_TRUE] = (zend_rc_dtor_func_t)zend_empty_destroy,
[IS_LONG] = (zend_rc_dtor_func_t)zend_empty_destroy,
[IS_DOUBLE] = (zend_rc_dtor_func_t)zend_empty_destroy,
[IS_STRING] = (zend_rc_dtor_func_t)zend_string_destroy,
[IS_ARRAY] = (zend_rc_dtor_func_t)zend_array_destroy,
[IS_OBJECT] = (zend_rc_dtor_func_t)zend_objects_store_del,
[IS_RESOURCE] = (zend_rc_dtor_func_t)zend_list_free,
[IS_REFERENCE] = (zend_rc_dtor_func_t)zend_reference_destroy,
[IS_CONSTANT_AST] = (zend_rc_dtor_func_t)zend_ast_ref_destroy
};

ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)
Expand Down