diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-15 22:32:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 22:32:42 +0000 |
commit | de9bb867970b755eca6ff612daae801f120ee928 (patch) | |
tree | d14617885960c60ecb777993479bbe967302ec02 /gcc | |
parent | 310968874db1902084012cf767ad0b6e93f028c2 (diff) | |
parent | 24dd9a6aef8493a46e61735b17c9c26bd7c164ef (diff) | |
download | gcc-de9bb867970b755eca6ff612daae801f120ee928.zip gcc-de9bb867970b755eca6ff612daae801f120ee928.tar.gz gcc-de9bb867970b755eca6ff612daae801f120ee928.tar.bz2 |
Merge #831
831: Fix out-of-bounds in typechecking of ADTTypes r=philberty a=philberty
In the case of an enum where there are more variants than the number of
fields within any variant we end up hitting an out of bounds exception
as we are using the wrong iterator on the fields during type checking.
This also means we were missing all possible fields in the case during
type checking.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-cmp.h | 4 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-coercion.h | 4 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-rules.h | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-cmp.h b/gcc/rust/typecheck/rust-tyty-cmp.h index a23855e..291e590 100644 --- a/gcc/rust/typecheck/rust-tyty-cmp.h +++ b/gcc/rust/typecheck/rust-tyty-cmp.h @@ -1021,8 +1021,8 @@ public: for (size_t j = 0; j < a->num_fields (); j++) { - TyTy::StructFieldType *base_field = a->get_field_at_index (i); - TyTy::StructFieldType *other_field = b->get_field_at_index (i); + TyTy::StructFieldType *base_field = a->get_field_at_index (j); + TyTy::StructFieldType *other_field = b->get_field_at_index (j); TyTy::BaseType *this_field_ty = base_field->get_field_type (); TyTy::BaseType *other_field_ty = other_field->get_field_type (); diff --git a/gcc/rust/typecheck/rust-tyty-coercion.h b/gcc/rust/typecheck/rust-tyty-coercion.h index 6525da3..b483130 100644 --- a/gcc/rust/typecheck/rust-tyty-coercion.h +++ b/gcc/rust/typecheck/rust-tyty-coercion.h @@ -1031,8 +1031,8 @@ public: for (size_t j = 0; j < a->num_fields (); j++) { - TyTy::StructFieldType *base_field = a->get_field_at_index (i); - TyTy::StructFieldType *other_field = b->get_field_at_index (i); + TyTy::StructFieldType *base_field = a->get_field_at_index (j); + TyTy::StructFieldType *other_field = b->get_field_at_index (j); TyTy::BaseType *this_field_ty = base_field->get_field_type (); TyTy::BaseType *other_field_ty = other_field->get_field_type (); diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h index f044d0e..5dc2d2f 100644 --- a/gcc/rust/typecheck/rust-tyty-rules.h +++ b/gcc/rust/typecheck/rust-tyty-rules.h @@ -1047,8 +1047,8 @@ public: for (size_t j = 0; j < a->num_fields (); j++) { - TyTy::StructFieldType *base_field = a->get_field_at_index (i); - TyTy::StructFieldType *other_field = b->get_field_at_index (i); + TyTy::StructFieldType *base_field = a->get_field_at_index (j); + TyTy::StructFieldType *other_field = b->get_field_at_index (j); TyTy::BaseType *this_field_ty = base_field->get_field_type (); TyTy::BaseType *other_field_ty = other_field->get_field_type (); |