]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: ICE in character(kind=4) deferred-length array reference [PR121939]
authorHarald Anlauf <anlauf@gmx.de>
Wed, 24 Sep 2025 18:57:21 +0000 (20:57 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 25 Sep 2025 16:51:48 +0000 (18:51 +0200)
PR fortran/121939

gcc/fortran/ChangeLog:

* trans-types.cc (gfc_init_types): Set string flag for all
character types.

gcc/testsuite/ChangeLog:

* gfortran.dg/deferred_character_39.f90: Disable temporary
workaround for character(kind=4) deferred-length bug.

gcc/fortran/trans-types.cc
gcc/testsuite/gfortran.dg/deferred_character_39.f90

index a9e512ed135d82cc1a80fa720c3c6f0e02dd3047..26645b0f7f6709028e2cbd268aa71e43c22471b5 100644 (file)
@@ -1135,6 +1135,7 @@ gfc_init_types (void)
     {
       type = gfc_build_uint_type (gfc_character_kinds[index].bit_size);
       type = build_qualified_type (type, TYPE_UNQUALIFIED);
+      TYPE_STRING_FLAG (type) = 1;
       snprintf (name_buf, sizeof(name_buf), "character(kind=%d)",
                gfc_character_kinds[index].kind);
       PUSH_TYPE (name_buf, type);
index 564f94bb9bde0252ef946dbde3242480f1ce5e42..38ec431fc60f03dab376dd8d818c131d04137af7 100644 (file)
@@ -1,5 +1,6 @@
 ! { dg-do run }
 ! PR fortran/108581 - issues with rank-2 deferred-length character arrays
+! PR fortran/121939 - ICE in gfc_conv_string_parameter
 
 program p
   call pr108581
@@ -79,8 +80,8 @@ subroutine test2
   allocate (a, source = reshape (str1,[1,size(str1)]))
   allocate (b, source = reshape (str1,[1,size(str1)]))
   allocate (c, source = reshape (str4,[1,size(str4)]))
-! allocate (d, source=c)        ! ICE, tracked as pr121939
-  d => c
+  allocate (d, source = c)      ! fixed with pr121939
+! d => c
   ! Positive non-unit stride
   s0 = concat (str1(1::2))
   write(s1,'(4A)') a(1,1::2)
@@ -124,13 +125,14 @@ subroutine test2
   if (s2 /= s0) stop 26
   if (s3 /= s0) stop 27
   if (s4 /= s0) stop 28
-  deallocate (a,b,c)
+  deallocate (a,b,c,d)
 
   ! More complex cases with shape=[2,4]
   allocate (e, source = reshape (str2,[2,size(str2,2)]))
   allocate (f, source = reshape (str2,[2,size(str2,2)]))
   allocate (g, source = reshape (str5,[2,size(str5,2)]))
-  h => g
+  allocate (h, source = reshape (str5,[2,size(str5,2)])) ! fixed with pr121939
+! h => g
   s0 = concat (str2(1,3:1:-2))
   write(s1,'(4A)') e(1,3:1:-2)
   write(s2,'(4A)') f(1,3:1:-2)
@@ -220,7 +222,7 @@ subroutine test2
   if (s2 /= s0) stop 66
   if (s3 /= s0) stop 67
   if (s4 /= s0) stop 68
-  deallocate (e,f,g)
+  deallocate (e,f,g,h)
 
 contains