]> granicus.if.org Git - php/commitdiff
Get rid of implicit type casting in GC_*() macros in Zend/zend_types.h.
authorDmitry Stogov <dmitry@zend.com>
Thu, 13 Aug 2015 10:56:29 +0000 (13:56 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 13 Aug 2015 10:56:29 +0000 (13:56 +0300)
This prevented compilation warnings and disclosed few incorrect usages in Zend/zend_vm_def.h and ext/dom/xpath.c.
Now explicit type casting may be required on call site.
This may break some C extension code, but it shoulfn't be a problem to add explicit casting.

Zend/zend_execute_API.c
Zend/zend_generators.c
Zend/zend_iterators.c
Zend/zend_objects_API.h
Zend/zend_types.h
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/dom/xpath.c
ext/intl/common/common_enum.cpp
ext/reflection/php_reflection.c
sapi/phpdbg/phpdbg_watch.c

index 983bc5c1e34109d78646cd877dde8f19680a8107..7b9dbce3ca9dc770247ec29adeca7f704fc0948f 100644 (file)
@@ -843,8 +843,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
                EG(scope) = func->common.scope;
                call->symbol_table = fci->symbol_table;
                if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) {
-                       ZEND_ASSERT(GC_TYPE(func->op_array.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(func->op_array.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)func->op_array.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)func->op_array.prototype)++;
                        ZEND_ADD_CALL_FLAG(call, ZEND_CALL_CLOSURE);
                }
                if (EXPECTED((func->op_array.fn_flags & ZEND_ACC_GENERATOR) == 0)) {
index 13997627029f6e2d495b82a349cfcaff1ed1e88b..9ca264b97e4afddf171e8c75a83296ac4d2977c9 100644 (file)
@@ -469,7 +469,7 @@ void zend_generator_yield_from(zend_generator *generator, zend_generator *from)
 
        generator->node.parent = from;
        zend_generator_get_current(generator);
-       --GC_REFCOUNT(from);
+       --GC_REFCOUNT(&from->std);
 }
 
 ZEND_API zend_generator *zend_generator_get_current(zend_generator *generator)
index 8914f081210c5ceb68c8bea50516b78234822921..f42ddf63b9d7cc5f020065f6d01d5a47d39fcf09 100644 (file)
@@ -81,7 +81,7 @@ ZEND_API void zend_iterator_init(zend_object_iterator *iter)
 
 ZEND_API void zend_iterator_dtor(zend_object_iterator *iter)
 {
-       if (--GC_REFCOUNT(iter) > 0) {
+       if (--GC_REFCOUNT(&iter->std) > 0) {
                return;
        }
 
index 5bc7d774bce2288a718585776d2e430d2688b53b..4497181add328bde1c421e2961abe899b473cdc4 100644 (file)
@@ -77,7 +77,7 @@ static zend_always_inline void zend_object_release(zend_object *obj)
        if (--GC_REFCOUNT(obj) == 0) {
                zend_objects_store_del(obj);
        } else if (UNEXPECTED(!GC_INFO(obj))) {
-               gc_possible_root(&obj->gc);
+               gc_possible_root((zend_refcounted*)obj);
        }
 }
 
index d4353f7d4deaca9ef615f62a5491ac6b8e1be6fd..1bbf7963ad3c394cb5d964a3e58b4d6727e2462f 100644 (file)
@@ -140,7 +140,7 @@ struct _zval_struct {
        } u2;
 };
 
-struct _zend_refcounted {
+typedef struct _zend_refcounted_h {
        uint32_t         refcount;                      /* reference counter 32-bit */
        union {
                struct {
@@ -151,10 +151,14 @@ struct _zend_refcounted {
                } v;
                uint32_t type_info;
        } u;
+} zend_refcounted_h;
+
+struct _zend_refcounted {
+       zend_refcounted_h gc;
 };
 
 struct _zend_string {
-       zend_refcounted   gc;
+       zend_refcounted_h gc;
        zend_ulong        h;                /* hash value */
        size_t            len;
        char              val[1];
@@ -169,7 +173,7 @@ typedef struct _Bucket {
 typedef struct _zend_array HashTable;
 
 struct _zend_array {
-       zend_refcounted   gc;
+       zend_refcounted_h gc;
        union {
                struct {
                        ZEND_ENDIAN_LOHI_4(
@@ -270,7 +274,7 @@ typedef struct _HashTableIterator {
 } HashTableIterator;
 
 struct _zend_object {
-       zend_refcounted   gc;
+       zend_refcounted_h gc;
        uint32_t          handle; // TODO: may be removed ???
        zend_class_entry *ce;
        const zend_object_handlers *handlers;
@@ -279,19 +283,19 @@ struct _zend_object {
 };
 
 struct _zend_resource {
-       zend_refcounted   gc;
+       zend_refcounted_h gc;
        int               handle; // TODO: may be removed ???
        int               type;
        void             *ptr;
 };
 
 struct _zend_reference {
-       zend_refcounted   gc;
+       zend_refcounted_h gc;
        zval              val;
 };
 
 struct _zend_ast_ref {
-       zend_refcounted   gc;
+       zend_refcounted_h gc;
        zend_ast         *ast;
 };
 
@@ -365,11 +369,11 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
 #define Z_TYPE_FLAGS_SHIFT                     8
 #define Z_CONST_FLAGS_SHIFT                    16
 
-#define GC_REFCOUNT(p)                         ((zend_refcounted*)(p))->refcount
-#define GC_TYPE(p)                                     ((zend_refcounted*)(p))->u.v.type
-#define GC_FLAGS(p)                                    ((zend_refcounted*)(p))->u.v.flags
-#define GC_INFO(p)                                     ((zend_refcounted*)(p))->u.v.gc_info
-#define GC_TYPE_INFO(p)                                ((zend_refcounted*)(p))->u.type_info
+#define GC_REFCOUNT(p)                         (p)->gc.refcount
+#define GC_TYPE(p)                                     (p)->gc.u.v.type
+#define GC_FLAGS(p)                                    (p)->gc.u.v.flags
+#define GC_INFO(p)                                     (p)->gc.u.v.gc_info
+#define GC_TYPE_INFO(p)                                (p)->gc.u.type_info
 
 #define Z_GC_TYPE(zval)                                GC_TYPE(Z_COUNTED(zval))
 #define Z_GC_TYPE_P(zval_p)                    Z_GC_TYPE(*(zval_p))
index c968fd290772243d45673962c546ac473bbf1caa..7260ecb7879272cdf81a0db5e9105b7946dc18c7 100644 (file)
@@ -3241,8 +3241,8 @@ ZEND_VM_C_LABEL(try_function_name):
                Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
                if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
                        /* Delay closure destruction until its invocation */
-                       ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(fbc->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)fbc->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)fbc->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                } else if (object) {
                        call_info |= ZEND_CALL_RELEASE_THIS;
@@ -3377,8 +3377,8 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV)
                        if (OP2_TYPE & (IS_VAR|IS_CV)) {
                                ZVAL_DEREF(function_name);
                        }
-                       ZEND_ASSERT(GC_TYPE(func->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(func->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)func->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                }
                called_scope = fcc.called_scope;
@@ -6727,9 +6727,11 @@ ZEND_VM_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, ANY)
                } else if (OP1_TYPE == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (OP1_TYPE == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -6765,9 +6767,11 @@ ZEND_VM_HANDLER(169, ZEND_COALESCE, CONST|TMP|VAR|CV, ANY)
                } else if (OP1_TYPE == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (OP1_TYPE == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
index 5645ed625a3a04768d9080ecea6f98098d156000..e5915e49dd14a8f20aa642550c5d33e506e6c434 100644 (file)
@@ -2016,8 +2016,8 @@ try_function_name:
                Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
                if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
                        /* Delay closure destruction until its invocation */
-                       ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(fbc->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)fbc->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)fbc->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                } else if (object) {
                        call_info |= ZEND_CALL_RELEASE_THIS;
@@ -2438,8 +2438,8 @@ try_function_name:
                Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
                if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
                        /* Delay closure destruction until its invocation */
-                       ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(fbc->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)fbc->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)fbc->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                } else if (object) {
                        call_info |= ZEND_CALL_RELEASE_THIS;
@@ -2693,8 +2693,8 @@ try_function_name:
                Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
                if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
                        /* Delay closure destruction until its invocation */
-                       ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(fbc->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)fbc->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)fbc->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                } else if (object) {
                        call_info |= ZEND_CALL_RELEASE_THIS;
@@ -4011,9 +4011,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CONST_HANDLER(ZEN
                } else if (IS_CONST == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_CONST == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -4048,9 +4050,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_CONST_HANDLER(ZE
                } else if (IS_CONST == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_CONST == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -5735,8 +5739,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CONS
                        if (IS_CONST & (IS_VAR|IS_CV)) {
                                ZVAL_DEREF(function_name);
                        }
-                       ZEND_ASSERT(GC_TYPE(func->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(func->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)func->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                }
                called_scope = fcc.called_scope;
@@ -9485,8 +9489,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CV_H
                        if (IS_CV & (IS_VAR|IS_CV)) {
                                ZVAL_DEREF(function_name);
                        }
-                       ZEND_ASSERT(GC_TYPE(func->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(func->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)func->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                }
                called_scope = fcc.called_scope;
@@ -11295,8 +11299,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMPV
                        if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) {
                                ZVAL_DEREF(function_name);
                        }
-                       ZEND_ASSERT(GC_TYPE(func->common.prototype) == IS_OBJECT);
-                       GC_REFCOUNT(func->common.prototype)++;
+                       ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT);
+                       GC_REFCOUNT((zend_object*)func->common.prototype)++;
                        call_info |= ZEND_CALL_CLOSURE;
                }
                called_scope = fcc.called_scope;
@@ -12371,9 +12375,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_
                } else if (IS_TMP_VAR == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_TMP_VAR == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -12409,9 +12415,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_TMP_HANDLER(ZEND
                } else if (IS_TMP_VAR == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_TMP_VAR == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -16203,9 +16211,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_
                } else if (IS_VAR == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_VAR == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -16241,9 +16251,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_VAR_HANDLER(ZEND
                } else if (IS_VAR == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_VAR == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -29412,9 +29424,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CV_HANDLER(ZEND_O
                } else if (IS_CV == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_CV == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
@@ -29449,9 +29463,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_CV_HANDLER(ZEND_
                } else if (IS_CV == IS_CV) {
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
                } else if (IS_CV == IS_VAR && ref) {
+                       zend_reference *r = Z_REF_P(ref);
+
                        if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
-                       if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
-                               efree_size(ref, sizeof(zend_reference));
+                       if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
+                               efree_size(r, sizeof(zend_reference));
                        }
                }
                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
index 6e7d7519c783accda279901448267805d97558d6..5dff89e37f8d463b3700645bd1ef67d971de717e 100644 (file)
@@ -209,7 +209,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
                                        ALLOC_HASHTABLE(intern->node_list);
                                        zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);
                                }
-                               GC_REFCOUNT(&retval)++;
+                               Z_ADDREF(retval);
                                zend_hash_next_index_insert(intern->node_list, &retval);
                                obj = Z_DOMOBJ_P(&retval);
                                nodep = dom_object_get_node(obj);
index e76f3b830f64f460837393ac9f6942f05756e7c3..0531a6b933e85a7a27d132673084af51483e1a50 100644 (file)
@@ -183,7 +183,7 @@ static zend_object_iterator *IntlIterator_get_iterator(
                return NULL;
        }
 
-       ++GC_REFCOUNT(ii->iterator);
+       ++GC_REFCOUNT(&ii->iterator->std);
 
        return ii->iterator;
 }
index 463cbd6a3a09e5cd86db9113d25da6d0f2e934fa..00731c70c39ecef268ff95e630cee94d2056bd80 100644 (file)
@@ -2314,7 +2314,7 @@ ZEND_METHOD(reflection_generator, getExecutingGenerator)
        REFLECTION_CHECK_VALID_GENERATOR(ex)
 
        current = zend_generator_get_current(generator);
-       ++GC_REFCOUNT(current);
+       ++GC_REFCOUNT(&current->std);
 
        ZVAL_OBJ(return_value, (zend_object *) current);
 }
index 8c36d512239b90b6daf3b061bc1a58df49a545ef..06a0bbefe81ff8c80628c163e7a0e2fb5ed13370 100644 (file)
@@ -185,7 +185,7 @@ static phpdbg_watchpoint_t *phpdbg_create_refcounted_watchpoint(phpdbg_watchpoin
        watch->parent = parent;
        watch->str = parent->str;
        ++GC_REFCOUNT(parent->str);
-       phpdbg_create_addr_watchpoint(&ref->refcount, sizeof(uint32_t), watch);
+       phpdbg_create_addr_watchpoint(&GC_REFCOUNT(ref), sizeof(uint32_t), watch);
        watch->type = WATCH_ON_REFCOUNTED;
 
        return watch;
@@ -1047,7 +1047,7 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump) {
                                                }
                                                if (Z_REFCOUNTED_P(watch->addr.zv)) {
                                                        if ((watch->flags & PHPDBG_WATCH_NORMAL) && (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS)) {
-                                                               phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\"", "New refcount: %d", Z_COUNTED_P(watch->addr.zv)->refcount);
+                                                               phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\"", "New refcount: %d", Z_REFCOUNT_P(watch->addr.zv));
                                                        }
                                                        if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
                                                                phpdbg_create_recursive_watchpoint(watch);
@@ -1079,8 +1079,8 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump) {
                                        break;
                                case WATCH_ON_REFCOUNTED: {
                                        if ((watch->flags & PHPDBG_WATCH_NORMAL) && (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS)) {
-                                               phpdbg_writeln("watchrefcount", "type=\"old\" refcount=\"%d\"", "Old refcount: %d", ((zend_refcounted *) oldPtr)->refcount);
-                                               phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\"", "New refcount: %d", watch->addr.ref->refcount);
+                                               phpdbg_writeln("watchrefcount", "type=\"old\" refcount=\"%d\"", "Old refcount: %d", GC_REFCOUNT((zend_refcounted *) oldPtr));
+                                               phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\"", "New refcount: %d", GC_REFCOUNT(watch->addr.ref));
                                        }
                                        break;
                                }