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

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Running under valgrind, it looks like it's a use-after-free error:

$ cat ../../src/z7.f90 
program p
   type t
      character(2), allocatable :: a(*)
      character(*), allocatable :: b(2)
      character(*), allocatable :: c(*)
   end type
end

$ ./gfortran -B. ../../src/z7.f90 -wrapper valgrind
==6758== Memcheck, a memory error detector
==6758== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==6758== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==6758== Command: ./f951 ../../src/z7.f90 -quiet -dumpbase z7.f90
-mtune=generic -march=x86-64 -auxbase z7 -fintrinsic-modules-path finclude -o
/tmp/ccdQqEXb.s
==6758== 
../../src/z7.f90:3:39:

       character(2), allocatable :: a(*)
                                       1
Error: Allocatable component of structure at (1) must have a deferred shape
../../src/z7.f90:4:39:

       character(*), allocatable :: b(2)
                                       1
Error: Allocatable component of structure at (1) must have a deferred shape
../../src/z7.f90:5:39:

       character(*), allocatable :: c(*)
                                       1
Error: Allocatable component of structure at (1) must have a deferred shape
==6758== Invalid read of size 8
==6758==    at 0x8399CF: resolve_fl_derived0(gfc_symbol*) (resolve.c:13196)
==6758==    by 0x83A53D: resolve_fl_derived(gfc_symbol*) (resolve.c:13402)
==6758==    by 0x83B161: resolve_symbol(gfc_symbol*) (resolve.c:13676)
==6758==    by 0x85DED8: do_traverse_symtree(gfc_symtree*, void
(*)(gfc_symtree*), void (*)(gfc_symbol*)) (symbol.c:3817)
==6758==    by 0x85DF93: gfc_traverse_ns(gfc_namespace*, void (*)(gfc_symbol*))
(symbol.c:3842)
==6758==    by 0x83F7B0: resolve_types(gfc_namespace*) (resolve.c:15465)
==6758==    by 0x83FC39: gfc_resolve(gfc_namespace*) (resolve.c:15575)
==6758==    by 0x813CD0: resolve_all_program_units(gfc_namespace*)
(parse.c:5551)
==6758==    by 0x814557: gfc_parse_file() (parse.c:5803)
==6758==    by 0x868BC5: gfc_be_parse_file() (f95-lang.c:201)
==6758==    by 0xF44FE3: compile_file() (toplev.c:465)
==6758==    by 0xF47FD2: do_compile() (toplev.c:1988)
==6758==  Address 0x4dba140 is 0 bytes inside a block of size 48 free'd
==6758==    at 0x4A07577: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6758==    by 0x85DA05: gfc_free_charlen(gfc_charlen*, gfc_charlen*)
(symbol.c:3664)
==6758==    by 0x80E7E0: reject_statement() (parse.c:2318)
==6758==    by 0x808C52: match_word(char const*, match (*)(), locus*)
(parse.c:70)
==6758==    by 0x809888: decode_statement() (parse.c:372)
==6758==    by 0x80CE20: next_free() (parse.c:1076)
==6758==    by 0x80D481: next_statement() (parse.c:1310)
==6758==    by 0x80EF6E: parse_derived() (parse.c:2672)
==6758==    by 0x810505: parse_spec(gfc_statement) (parse.c:3368)
==6758==    by 0x813252: parse_progunit(gfc_statement) (parse.c:5189)
==6758==    by 0x814222: gfc_parse_file() (parse.c:5698)
==6758==    by 0x868BC5: gfc_be_parse_file() (f95-lang.c:201)

(this is with r233261)

Reply via email to