https://gcc.gnu.org/g:f28f15033d39cc1f00f119f7f1820c5de0d47f5d
commit f28f15033d39cc1f00f119f7f1820c5de0d47f5d Author: Mikael Morin <mik...@gcc.gnu.org> Date: Wed Jun 18 22:11:43 2025 +0200 Ajout test gcc/testsuite/ChangeLog: * gfortran.dg/save_alloc_character_1.f90: New test. Diff: --- .../gfortran.dg/save_alloc_character_1.f90 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/testsuite/gfortran.dg/save_alloc_character_1.f90 b/gcc/testsuite/gfortran.dg/save_alloc_character_1.f90 new file mode 100644 index 000000000000..ac16e77a01f4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/save_alloc_character_1.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! +! Check that the length variable of SAVEd allocatable character arrays are +! not initialized at function entry. + +program p + implicit none + call s(1) + call s(2) +contains + subroutine s(i) + integer, intent(in) :: i + character(len=:), allocatable, save :: a(:) + integer :: j + if (i == 1) then + allocate(a, source= [ ('x' // achar(ichar('0') + j), j=1,7) ]) + else + if (len(a) /= 2) error stop 1 + if (any(a /= ['x1','x2','x3','x4','x5','x6','x7'])) error stop 2 + end if + end subroutine s +end program p