https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82721
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkoenig at gcc dot gnu.org --- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Valgrind reports the problem as asdf.f90:3:25: 3 | character(len(c)) :: b | 1 Fehler: Symbol »b« bei (1) hat bereits grundlegenden Typen REAL ==28874== Invalid read of size 8 ==28874== at 0x8CD014: check_host_association (resolve.c:5756) ==28874== by 0x8CD014: gfc_resolve_expr(gfc_expr*) (resolve.c:6879) ==28874== by 0x8D1A98: resolve_index_expr(gfc_expr*) (resolve.c:11927) ==28874== by 0x8D1BD4: resolve_charlen(gfc_charlen*) [clone .part.0] (resolve.c:11979) .. ==28874== Address 0x5872a18 is 40 bytes inside a block of size 48 free'd ==28874== at 0x4C2B390: free (vg_replace_malloc.c:530) ==28874== by 0x8EF361: gfc_delete_symtree(gfc_symtree**, char const*) (symbol.c:2962) ==28874== by 0x8F09F1: gfc_restore_last_undo_checkpoint() (symbol.c:3714) ==28874== by 0x8ABE87: reject_statement() (parse.c:2576) ==28874== by 0x8AC9C1: match_word (parse.c:70) ==28874== by 0x8AC9C1: decode_statement() (parse.c:376) ... Looking at where the error is issued, gfc_add_type notices that there already is a symbol, hands this up to build_sym, which returns false to variable_decl, and when things finally go up all the way to match_word, reject_statement() deletes the symtree.