[Patch, fortran] PR51976 - [F2003] Support deferred-length character components of derived types (allocatable string length)

W Spector w6ws@earthlink.net
Sun Mar 9 15:38:00 GMT 2014


> I have just committed the patch as r208386, thereby implementing
> deferred-length character components on 4.9 trunk. One big plea to the
> users: Please test this as soon as possible!

Janus - I have updated my test compiler to the current trunk.  A couple 
of things:

1.) I can reproduce the 'gimplification' ICE in comment #8 with the 
ALLOCATE statement,

2.) I can reproduce the 'No initializer for component...' error also 
mentioned in comment #8,

3.) My example in comment #12 appears to work fine.  However when 
running the example under valgrind, memory leaks are indicated.  I cut 
the example down quite a bit, and it seems that there are leaks 
regardless of whether derived types are used or not.  So this isn't a 
regression due to this patch, but something that has been around for a 
while:

wws@w6ws-4:~/fortran/strings$ cat deflen_test5.f90
program strings
   implicit none

   character(:), allocatable :: string

   string = "first string"
   print *, string
   string = "second string"
   print *, string
   string = "3rd string"
   print *, string

end program
wws@w6ws-4:~/fortran/strings$ /usr/local/gcc-trunk/bin/gfortran 
--version deflen_test5.f90
GNU Fortran (GCC) 4.9.0 20140306 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

wws@w6ws-4:~/fortran/strings$ valgrind --leak-check=full a.out
==3153== Memcheck, a memory error detector
==3153== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3153== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3153== Command: a.out
==3153==
  first string
  second string
  3rd string
==3153==
==3153== HEAP SUMMARY:
==3153==     in use at exit: 10 bytes in 1 blocks
==3153==   total heap usage: 24 allocs, 23 frees, 11,851 bytes allocated
==3153==
==3153== 10 bytes in 1 blocks are definitely lost in loss record 1 of 1
==3153==    at 0x4C2B4F0: realloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3153==    by 0x400B0E: MAIN__ (in /home/wws/fortran/strings/a.out)
==3153==    by 0x400C12: main (in /home/wws/fortran/strings/a.out)
==3153==
==3153== LEAK SUMMARY:
==3153==    definitely lost: 10 bytes in 1 blocks
==3153==    indirectly lost: 0 bytes in 0 blocks
==3153==      possibly lost: 0 bytes in 0 blocks
==3153==    still reachable: 0 bytes in 0 blocks
==3153==         suppressed: 0 bytes in 0 blocks
==3153==
==3153== For counts of detected and suppressed errors, rerun with: -v
==3153== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
wws@w6ws-4:~/fortran/strings$


Walter



More information about the Fortran mailing list