phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

[BUG]: [-Wincompatible-pointer-types] build warning [5.0.0alpha7] #15792

Open remicollet opened 2 years ago

remicollet commented 2 years ago

In various place:

In file included from /usr/include/php/Zend/zend_types.h:25,
                 from /usr/include/php/Zend/zend.h:27,
                 from /usr/include/php/main/php.h:31,
                 from /builddir/build/BUILD/php-phalcon5-5.0.0~alpha7/NTS/phalcon.zep.c:46:
/builddir/build/BUILD/php-phalcon5-5.0.0~alpha7/NTS/phalcon.zep.c: In function 'zim_Phalcon_Cache_Cache_checkKey':
/usr/include/php/Zend/zend_API.h:1775:44: warning: passing argument 2 of 'zend_parse_arg_str' from incompatible pointer type [-Wincompatible-pointer-types]
   if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \
/usr/include/php/Zend/zend_portability.h:325:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^~~~~~~~~
/usr/include/php/Zend/zend_API.h:1782:2: note: in expansion of macro 'Z_PARAM_STR_EX2'
  Z_PARAM_STR_EX2(dest, check_null, separate, separate)
  ^~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_API.h:1785:2: note: in expansion of macro 'Z_PARAM_STR_EX'
  Z_PARAM_STR_EX(dest, 0, 0)
  ^~~~~~~~~~~~~~
/builddir/build/BUILD/php-phalcon5-5.0.0~alpha7/NTS/phalcon.zep.c:221588:3: note: in expansion of macro 'Z_PARAM_STR'
   Z_PARAM_STR(key)
   ^~~~~~~~~~~
In file included from /usr/include/php/main/php.h:35,
                 from /builddir/build/BUILD/php-phalcon5-5.0.0~alpha7/NTS/phalcon.zep.c:46:
/usr/include/php/Zend/zend_API.h:1947:76: note: expected 'zend_string **' {aka 'struct _zend_string **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}

In code we have

    zval key;
        ...
        Z_PARAM_STR(key)

So key should be a zend_string.

remicollet commented 2 years ago

Notice: build from the git tag (the content of the phalcon-pecl.tgz asset seems very different)

Jeckerson commented 2 years ago

Relates to https://github.com/zephir-lang/zephir/issues/1902

remicollet commented 2 years ago

I don't think this is related to linked issue, which is about refactoring to take benefit of zend_string usage

This one is about a bad pointer cast, a zval cannot be used where a zend_string is expected, so a real issue.

Jeckerson commented 2 years ago

@remicollet Zephir's issue mentioned before, will be used as reference to review and refactor of char, zval and zend_string structs.

Jeckerson commented 2 years ago

Blocked by https://github.com/zephir-lang/zephir/issues/2326