Skip to content
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

Bugs with Chars #1988

Open
sergeyklay opened this issue Oct 28, 2019 · 1 comment
Open

Bugs with Chars #1988

sergeyklay opened this issue Oct 28, 2019 · 1 comment
Labels

Comments

@sergeyklay
Copy link
Member

sergeyklay commented Oct 28, 2019

Failed to compile

char ch = 'A';
printf("The value of '%s' is %c", ch, (char)ch);
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c: In function ‘zim_Bug_Chars_sum’:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:151:31: note: in expansion of macro ‘Z_TYPE_P’
 #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
                               ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:49:14: note: in expansion of macro ‘zephir_get_intval’
  _0 = (char) zephir_get_intval(&chlower);
              ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:572:31: error: request for member ‘value’ in something not a structure or union
 #define Z_LVAL(zval)    (zval).value.lval
                               ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:573:28: note: in expansion of macro ‘Z_LVAL’
 #define Z_LVAL_P(zval_p)   Z_LVAL(*(zval_p))
                            ^~~~~~
./kernel/operators.h:151:56: note: in expansion of macro ‘Z_LVAL_P’
 #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
                                                        ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:49:14: note: in expansion of macro ‘zephir_get_intval’
  _0 = (char) zephir_get_intval(&chlower);
              ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:15:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:49:32: warning: passing argument 1 of ‘zephir_get_intval_ex’ from incompatible pointer type [-Wincompatible-pointer-types]
  _0 = (char) zephir_get_intval(&chlower);
                                ^~~~~~~~
./kernel/operators.h:151:91: note: in definition of macro ‘zephir_get_intval’
 #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
                                                                                           ^
./kernel/operators.h:108:39: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 long zephir_get_intval_ex(const zval *op);
                           ~~~~~~~~~~~~^~
make: *** [Makefile:238: bug/chars.lo] Error 1
make: *** Waiting for unfinished jobs....

Return array of

    public function extract()
    {
        char ch1, ch2;
        string name = "peter";

        let ch1 = name[0],
            ch2 = name[1];

        return [ch1, ch2, ch1];

    }

[ERROR] Unknown char


Cast to string

    public function extract()
    {
        char ch1, ch2;
        string name = "peter";

        let ch1 = name[0],
            ch2 = name[1];

        return [
            "sprintf": sprintf("%s%s%s%s", ch1, ch2, ch1, ch2),
            "cast": (string)ch1 . (string)ch2 . (string)ch1 . (string)ch2
        ];
    }
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c: In function ‘zim_Bug_Chars_extract’:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_6, &ch1);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_6, &ch1);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_7, &ch2);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_7, &ch2);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_8, &ch1);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_8, &ch1);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_9, &ch2);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_9, &ch2);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
make: *** [Makefile:238: bug/chars.lo] Error 1
make: *** Waiting for unfinished jobs....

Strange chr result

    public function extract()
    {
        char ch1, ch2;
        string name = "peter";

        let ch1 = name[0],
            ch2 = name[1];

        return [
            "sprintf": sprintf("%s%s%s%s", ch1, ch2, ch1, ch2),
            "cast": chr(ch1) . chr(ch2) . chr(ch1) . chr(ch2)
        ];
    }
$t = new Bug\Chars;
var_dump($t->extract());
array(2) {
  ["sprintf"]=>
  string(4) "pepe"
  ["cast"]=>
  string(4) ""
}
@sergeyklay
Copy link
Member Author

Casting was fixed in #1992

sergeyklay added a commit that referenced this issue Nov 2, 2019
sergeyklay added a commit that referenced this issue Nov 2, 2019
sergeyklay added a commit that referenced this issue Nov 2, 2019
sergeyklay added a commit that referenced this issue Nov 2, 2019
dreamsxin pushed a commit to dreamsxin/zephir that referenced this issue Nov 6, 2019
dreamsxin pushed a commit to dreamsxin/zephir that referenced this issue Nov 6, 2019
dreamsxin pushed a commit to dreamsxin/zephir that referenced this issue Nov 6, 2019
@sergeyklay sergeyklay removed their assignment Sep 7, 2020
@Jeckerson Jeckerson added this to the 0.13.x milestone Apr 13, 2021
@Jeckerson Jeckerson modified the milestones: 0.13.x, 0.14.x Sep 12, 2021
@Jeckerson Jeckerson modified the milestones: 0.14.x, Backlog Oct 3, 2021
@Jeckerson Jeckerson removed this from the Backlog milestone Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants