diff options
-rw-r--r-- | gcc/rust/backend/rust-constexpr.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3563.rs | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 2f2bbbd..dc2d6b1 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -2697,10 +2697,8 @@ eval_store_expression (const constexpr_ctx *ctx, tree t, bool lval, } if (TREE_CODE (probe) == ARRAY_REF) { - // TODO - rust_unreachable (); - // elt = eval_and_check_array_index (ctx, probe, false, - // non_constant_p, overflow_p); + elt = eval_and_check_array_index (ctx, probe, false, + non_constant_p, overflow_p); if (*non_constant_p) return t; } diff --git a/gcc/testsuite/rust/compile/issue-3563.rs b/gcc/testsuite/rust/compile/issue-3563.rs new file mode 100644 index 0000000..46e7624 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3563.rs @@ -0,0 +1,17 @@ +pub struct AA { + pub data: [u8; 10], +} + +impl AA { + pub const fn new() -> Self { + let mut res: AA = AA { data: [0; 10] }; + res.data[0] = 5; + res + } +} + +static mut BB: AA = AA::new(); + +fn main() { + let _ptr = unsafe { &mut BB }; +} |