diff --git a/releasenotes.md b/releasenotes.md index c12c93d23..bf087acf0 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -46,6 +46,7 @@ - Resolving a missing property on a const enum with inline, reached an assert #2597. - Unexpected maybe-deref subscript error with out parameter #2600. - Bug on rethrow in return with defer #2603. +- Fix bug when converting from vector to distinct type of wider vector. #2604 ### Stdlib changes - Add `CGFloat` `CGPoint` `CGSize` `CGRect` types to core_foundation (macOS). diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index ac4e573c6..1636f7afc 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -2020,8 +2020,7 @@ static void cast_vec_to_vec(Expr *expr, Type *to_type) // Extract indexed types. Type *from_type = type_flatten(expr->type); Type *from_element = from_type->array.base; - to_type = type_flatten(to_type); - Type *to_element = to_type->array.base; + Type *to_element = type_flatten(to_type)->array.base; // float vec -> float/int/bool vec if (type_is_float(from_element)) diff --git a/test/test_suite/bitstruct/cast_distinct_vec_to_other_vec.c3t b/test/test_suite/bitstruct/cast_distinct_vec_to_other_vec.c3t new file mode 100644 index 000000000..b6c292c5a --- /dev/null +++ b/test/test_suite/bitstruct/cast_distinct_vec_to_other_vec.c3t @@ -0,0 +1,10 @@ +typedef Foo = char[<4>]; + +fn int main() +{ + int[<4>] a; + Foo f = (Foo)a; + return 0; +} + +fn void thing() {}