Skip to content

Fix compiler warning (the comparison will always evaluate as ‘true’ for ZEND_OBSERVER_DATA(func) != NULL) #16650

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

Closed
wants to merge 1 commit into from

Conversation

arnaud-lb
Copy link
Member

This fixes the following warning with gcc 14:

ext/zend_test/observer.c: In function ‘zend_test_observer_OnUpdateCommaList’:
ext/zend_test/observer.c:318:115: error: the comparison will always evaluate as ‘true’ for the pointer operand in ‘(((long unsigned int)func->common.run_time_cache__ptr & 1) != 0 ? (void **)*((void **)compiler_globals.map_ptr_base + (sizetype)func->common.run_time_cache__ptr) : func->common.run_time_cache__ptr) + (((unsigned char)func->type) != 1 ? (sizetype)((long unsigned int)zend_observer_fcall_op_array_extension * 8) : (sizetype)((long unsigned int)zend_observer_fcall_internal_function_extension * 8))’ must not be NULL [-Werror=address]
  318 |                         if ((func = zend_hash_find_ptr(EG(function_table), funcname)) && ZEND_OBSERVER_DATA(func) != NULL) {
      |                                                                                                                   ^~
ext/zend_test/observer.c:341:123: error: the comparison will always evaluate as ‘true’ for the pointer operand in ‘(((long unsigned int)func->common.run_time_cache__ptr & 1) != 0 ? (void **)*((void **)compiler_globals.map_ptr_base + (sizetype)func->common.run_time_cache__ptr) : func->common.run_time_cache__ptr) + (((unsigned char)func->type) != 1 ? (sizetype)((long unsigned int)zend_observer_fcall_op_array_extension * 8) : (sizetype)((long unsigned int)zend_observer_fcall_internal_function_extension * 8))’ must not be NULL [-Werror=address]
  341 |                                 if ((func = zend_hash_find_ptr(EG(function_table), funcname)) && ZEND_OBSERVER_DATA(func) != NULL) {
      |                                                                                                                           ^~

This looks similar to #13923, but I believe that the warning is right in this case: ZEND_OBSERVER_DATA(func) can not be NULL as it takes the address of ZEND_OP_ARRAY_EXTENSION(...).

@arnaud-lb arnaud-lb requested a review from cmb69 October 30, 2024 11:26
@arnaud-lb arnaud-lb changed the base branch from master to PHP-8.4 October 30, 2024 11:26
@arnaud-lb arnaud-lb changed the title Fix compiler warning Fix compiler warning (the comparison will always evaluate as ‘true’ for ZEND_OBSERVER_DATA(func) != NULL) Oct 30, 2024
@iluuu1994
Copy link
Member

There was a short discussion, in case you missed it:
#16438 (review)

@arnaud-lb
Copy link
Member Author

Ah, I missed it. Thank you!

@arnaud-lb arnaud-lb closed this Oct 30, 2024
@iluuu1994
Copy link
Member

@cmb69 Would it be ok to merge this for now? It will be blocking the upgrade to Ubuntu 24.04, where this warning appears, without dropping -Werror.

@cmb69
Copy link
Member

cmb69 commented Nov 5, 2024

@iluuu1994, oh, totally missed the proper fix (busy with Windows lib updates). So yes, please merge this.

@iluuu1994 iluuu1994 reopened this Nov 5, 2024
@iluuu1994 iluuu1994 closed this in 8d30ed4 Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants