https://gcc.gnu.org/g:725f4e741e13be79bc1c6684346ec16f522d8a76
commit r17-4105-g725f4e741e13be79bc1c6684346ec16f522d8a76 Author: Lishin <[email protected]> Date: Sat Jul 25 14:31:42 2026 +0000 gccrs: Fix sized BIR IndexVec construction Create the requested number of elements in the IndexVec constructor instead of only reserving space. This fixes an out-of-bounds access when dumping BIR. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h (IndexVec::IndexVec): Create the requested number of elements. Signed-off-by: Lishin <[email protected]> Diff: --- gcc/rust/checks/errors/borrowck/rust-bir-place.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h index e7a31b9df6dc..d11ded9c9daa 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h @@ -209,7 +209,7 @@ template <typename I, typename T> class IndexVec public: IndexVec () = default; - IndexVec (size_t size) { internal_vector.reserve (size); } + IndexVec (size_t size) : internal_vector (size) {} T &at (I pid) { return internal_vector[pid.value]; } const T &at (I pid) const { return internal_vector[pid.value]; }
