diff --git a/lib/std/io/io_file.c3 b/lib/std/io/io_file.c3 index 9831528fd..881f67a02 100644 --- a/lib/std/io/io_file.c3 +++ b/lib/std/io/io_file.c3 @@ -109,7 +109,7 @@ fn usz! File.read(self, char[] buffer) */ fn usz! File.read_any(self, any ref) { - return self.read(((char*)ref.ptr)[:ref.type.sizeof]); + return self.read(ref.ptr[:ref.type.sizeof]); } /** @@ -128,7 +128,7 @@ fn usz! File.write(self, char[] buffer) */ fn usz! File.write_any(self, any ref) { - return self.write(((char*)ref.ptr)[:ref.type.sizeof]); + return self.write(ref.ptr[:ref.type.sizeof]); } /** diff --git a/lib/std/io/io_printf.c3 b/lib/std/io/io_printf.c3 index d1e4949fa..096d99f25 100644 --- a/lib/std/io/io_printf.c3 +++ b/lib/std/io/io_printf.c3 @@ -232,6 +232,7 @@ fn void! Formatter.out_str(&self, any arg) @private { return self.out_substr(*(String*)arg); } + if (inner == void.typeid) inner = char.typeid; usz size = inner.sizeof; // Pretend this is a String String* temp = (void*)arg.ptr; diff --git a/lib/std/io/io_stream.c3 b/lib/std/io/io_stream.c3 index 9109792ca..0204bd4e4 100644 --- a/lib/std/io/io_stream.c3 +++ b/lib/std/io/io_stream.c3 @@ -79,7 +79,7 @@ fn usz! Stream.available(self) @inline fn usz! Stream.read_any(self, any ref) { - return self.read(((char*)ref.ptr)[:ref.type.sizeof]); + return self.read(ref.ptr[:ref.type.sizeof]); } /** @@ -89,7 +89,7 @@ fn usz! Stream.read_any(self, any ref) */ fn usz! Stream.write_any(self, any ref) { - return self.write(((char*)ref.ptr)[:ref.type.sizeof]); + return self.write(ref.ptr[:ref.type.sizeof]); } diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 38f89695c..f020c57a2 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -474,7 +474,9 @@ static bool array_to_vector(Expr *expr, Type *to_type) */ INLINE bool subarray_to_subarray(Expr *expr, Type *to_type) { - if (expr_is_const(expr) || type_flatten(type_flatten(to_type)->array.base) == type_flatten(type_flatten(expr->type)->array.base)) + Type *to_type_base = type_flatten(type_flatten(to_type)->array.base); + Type *from_type_base = type_flatten(type_flatten(expr->type)->array.base); + if (expr_is_const(expr) || to_type_base == from_type_base || (to_type_base == type_void || from_type_base == type_void)) { // Here we assume int[] -> float[] can't happen. expr->type = to_type; diff --git a/src/compiler/types.c b/src/compiler/types.c index 72fc9c9ad..70a49569a 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -1662,6 +1662,10 @@ TypeCmpResult type_array_element_is_equivalent(SemaContext *context, Type *eleme element2 = element2->canonical; } if (element1 == element2) return TYPE_SAME; + if ((element1 == type_void && element2 == type_char) || (element1 == type_char && element2 == type_void)) + { + return TYPE_SAME; + } switch (element1->type_kind) { case TYPE_POINTER: