https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128141

            Bug ID: 128141
           Summary: valgrind error in
                    gfc_resolve_character_array_constructor(gfc_expr*)
                    (array.cc:2433)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

This F90 code, 

module m1
Type ty0(k1,k2)
         Integer, kind :: k1,k2
         character :: arr2(3) = [character(k2,k1)::'A','B','C']
End type

Type ty1(k1,k2)
         Integer, kind :: k1,k2
         character :: arr2(3) = [character(2,1)::'A','B','C']
End type

           Type (ty0(1,1)):: obj4
           Type (ty1(2,1)):: obj5

end module m1
use m1,only:aa=>obj5
use m1

if(any(aa%arr2   .ne. ['A','B','C']))print*,101
if(any(obj4%arr2   .ne. ['A','B','C']))print*,102
print*,"PASS"
End

when compiled by a recent valgrinded gfortran, does this:

$ ~/gcc/results.20261020.valgrind/bin/gfortran  -c -w
/home/dcb42/fujitsu/trunk/Fortran/0566/0566_0003.f90
==159098== Invalid read of size 8
==159098==    at 0x48951E: gfc_resolve_character_array_constructor(gfc_expr*)
(array.cc:2433)
==159098==    by 0x5809B9: gfc_resolve_expr(gfc_expr*) [clone .part.0]
(resolve.cc:8425)
==159098==    by 0x57DBD9: gfc_resolve_expr (resolve.cc:8339)
==159098==    by 0x57DBD9: resolve_structure_cons(gfc_expr*, int)
(resolve.cc:1381)

This is another test case from the fujitsu Fortran test suite on github.com.

The broken line of code in gfortran is  

       if (p->expr->ts.u.cl && p->expr->ts.u.cl->length)

git blame says:

50d263beff7 gcc/fortran/array.cc (Christopher Albert       2025-11-25 00:13:03
+0100 2433)         if (p->expr->ts.u.cl && p->expr->ts.u.cl->length)

Reply via email to