From 9d6666f333cd427a720c639ee0b9b513d79fe8a0 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 14 Dec 2018 21:58:12 +0000 Subject: Disallow casting between `cstring` and `[]u8` --- src/check_expr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 37a54854c..1e487fb00 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1926,11 +1926,11 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) { return true; } - // []byte/[]u8 <-> string - if (is_type_u8_slice(src) && is_type_string(dst)) { + // []byte/[]u8 <-> string (not cstring) + if (is_type_u8_slice(src) && (is_type_string(dst) && !is_type_cstring(dst))) { return true; } - if (is_type_string(src) && is_type_u8_slice(dst)) { + if ((is_type_string(src) && !is_type_cstring(src)) && is_type_u8_slice(dst)) { // if (is_type_typed(src)) { return true; // } -- cgit v1.2.3