From df825506fd3cd7632f79080b8d6f121ec4ef9ef3 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 11 Apr 2020 18:25:25 +0300 Subject: [PATCH] cgen: fix check for array equality --- vlib/v/gen/cgen.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index d6acfe6526..70d2a8f3f3 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2084,11 +2084,11 @@ fn (g mut Gen) generate_array_equality_fn(ptr_typ string, styp table.Type, sym & g.definitions.writeln('\t}') g.definitions.writeln('\tfor (int i = 0; i < a.len; i++) {') if styp == table.string_type_idx { - g.definitions.writeln('\t\tif (string_ne(*((${ptr_typ}*)(a.data+(i*a.element_size))), *((${ptr_typ}*)(b.data+(i*b.element_size))))) {') + g.definitions.writeln('\t\tif (string_ne(*((${ptr_typ}*)((byte*)a.data+(i*a.element_size))), *((${ptr_typ}*)((byte*)b.data+(i*b.element_size))))) {') } else if sym.kind == .struct_ { - g.definitions.writeln('\t\tif (memcmp((void*)(a.data+(i*a.element_size)), (void*)(b.data+(i*b.element_size)), a.element_size)) {') + g.definitions.writeln('\t\tif (memcmp((byte*)a.data+(i*a.element_size), (byte*)b.data+(i*b.element_size), a.element_size)) {') } else { - g.definitions.writeln('\t\tif (*((${ptr_typ}*)(a.data+(i*a.element_size))) != *((${ptr_typ}*)(b.data+(i*b.element_size)))) {') + g.definitions.writeln('\t\tif (*((${ptr_typ}*)((byte*)a.data+(i*a.element_size))) != *((${ptr_typ}*)((byte*)b.data+(i*b.element_size)))) {') } g.definitions.writeln('\t\t\treturn false;') g.definitions.writeln('\t\t}')