]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: fix ice when setting up regions
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 28 Mar 2025 18:24:57 +0000 (18:24 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 31 Mar 2025 19:07:25 +0000 (21:07 +0200)
num regions is based on the used arguments of regions which can be
less than the substutions requirements. So lets check for that and allow
anon regions to be created for them.

Fixes Rust-GCC#3605

gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.h: check for min range

gcc/testsuite/ChangeLog:

* rust/compile/issue-3605.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-tyty-subst.h
gcc/testsuite/rust/compile/issue-3605.rs [new file with mode: 0644]

index b8e928d60f03fef1dbd221f43bf3150a65b02c9d..3f0b912fa7b0fc0cda04cbe885ed0984efa25796 100644 (file)
@@ -125,7 +125,7 @@ public:
                                     std::vector<Region> subst)
   {
     RegionParamList list (num_regions);
-    for (size_t i = 0; i < subst.size (); i++)
+    for (size_t i = 0; i < MIN (num_regions, subst.size ()); i++)
       list.regions.at (i) = subst.at (i);
     for (size_t i = subst.size (); i < num_regions; i++)
       {
diff --git a/gcc/testsuite/rust/compile/issue-3605.rs b/gcc/testsuite/rust/compile/issue-3605.rs
new file mode 100644 (file)
index 0000000..05e6e48
--- /dev/null
@@ -0,0 +1,5 @@
+enum Foo<'a> {}
+
+enum Bar<'a> {
+    in_band_def_explicit_impl(Foo<'a>),
+}