aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-03-28 16:59:33 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-31 21:07:24 +0200
commita0b0d2a58ec8b830d0a88039709e2002b32dc2a8 (patch)
treef9d067592cb810330809ac4bca4eb157db1b9ace /gcc/testsuite/rust
parent453616bd98429e78ebb9db55cc4d89b45bf9a3b0 (diff)
downloadgcc-a0b0d2a58ec8b830d0a88039709e2002b32dc2a8.zip
gcc-a0b0d2a58ec8b830d0a88039709e2002b32dc2a8.tar.gz
gcc-a0b0d2a58ec8b830d0a88039709e2002b32dc2a8.tar.bz2
gccrs: Fix ICE in array ref constexpr
Since 898d55ad7e2 was fixed to remove the VIEW_CONVERT_EXPR from array expressions we can now turn on the array element access const expr. Fixes Rust-GCC#3563 gcc/rust/ChangeLog: * backend/rust-constexpr.cc (eval_store_expression): turn this back on gcc/testsuite/ChangeLog: * rust/compile/issue-3563.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r--gcc/testsuite/rust/compile/issue-3563.rs17
1 files changed, 17 insertions, 0 deletions
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 };
+}