http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51635

--- Comment #13 from Markus Trippelsdorf <markus at trippelsdorf dot de> 
2011-12-21 12:55:21 UTC ---
(In reply to comment #11)
> One issue we still hit is that we for example merge in
> stl_iterator_base_types.h
> 
>   template<typename _Iterator>
>     struct iterator_traits                
>     { 
>       typedef typename _Iterator::iterator_category iterator_category;
>       typedef typename _Iterator::value_type        value_type;
>       typedef typename _Iterator::difference_type   difference_type;
>       typedef typename _Iterator::pointer           pointer;
>       typedef typename _Iterator::reference         reference;
>     };
> 
> and
> 
>   template<typename _Tp>                  
>     struct iterator_traits<const _Tp*>    
>     { 
>       typedef random_access_iterator_tag iterator_category;
>       typedef _Tp                         value_type;
>       typedef ptrdiff_t                   difference_type;
>       typedef const _Tp*                  pointer;
>       typedef const _Tp&                  reference;
>     };
> 
> and so end up attaching the same TYPE_DECL to both iterator_category typedefs.
> An extreme idea was to only merge if the TYPE_DECLs source location was the
> same (but not sure if that works reliably without expensive location
> expansion).
> 
> The above merging causes us to infinitely recurse in modified_type_die
> through DECL_ORIGINAL_TYPE which forms a typedef cycle.  You probably
> hit a similar bug.
> 
> A non-optimial patch for the above is (non-optimal because it does not
> include hashing)
> 
> Index: gcc/gimple.c
> ===================================================================
> --- gcc/gimple.c        (revision 182525)
> +++ gcc/gimple.c        (working copy)
> @@ -3318,28 +3318,35 @@ compare_type_names_p (tree t1, tree t2)
>    tree name1 = TYPE_NAME (t1);
>    tree name2 = TYPE_NAME (t2);
> 
> +  if (name1 == name2)
> +    return true;
> +
>    if ((name1 != NULL_TREE) != (name2 != NULL_TREE))
>      return false;
> 
> -  if (name1 == NULL_TREE)
> -    return true;
> -
>    /* Either both should be a TYPE_DECL or both an IDENTIFIER_NODE.  */
>    if (TREE_CODE (name1) != TREE_CODE (name2))
>      return false;
> 
>    if (TREE_CODE (name1) == TYPE_DECL)
> -    name1 = DECL_NAME (name1);
> -  gcc_checking_assert (!name1 || TREE_CODE (name1) == IDENTIFIER_NODE);
> +    {
> +      expanded_location loc1, loc2;
> 
> -  if (TREE_CODE (name2) == TYPE_DECL)
> -    name2 = DECL_NAME (name2);
> -  gcc_checking_assert (!name2 || TREE_CODE (name2) == IDENTIFIER_NODE);
> +      if (DECL_NAME (name1) != DECL_NAME (name2))
> +       return false;
> 
> -  /* Identifiers can be compared with pointer equality rather
> -     than a string comparison.  */
> -  if (name1 == name2)
> -    return true;
> +      if (DECL_SOURCE_LOCATION (name1) == DECL_SOURCE_LOCATION (name2))
> +       return true;
> +
> +      loc1 = expand_location (DECL_SOURCE_LOCATION (name1));
> +      loc2 = expand_location (DECL_SOURCE_LOCATION (name2));
> +      if (loc1.line != loc2.line
> +         || loc1.column != loc2.column
> +         || strcmp (loc1.file, loc2.file) != 0)
> +       return false;
> +
> +      return true;
> +    }
> 
>    return false;
>  }

Program received signal SIGSEGV, Segmentation fault.
[Switching to process 30844]
strcmp () at ../sysdeps/x86_64/strcmp.S:214
214             movlpd  (%rsi), %xmm2
(gdb) bt
#0  strcmp () at ../sysdeps/x86_64/strcmp.S:214
#1  0x00000000005bff0f in compare_type_names_p (t1=<optimized out>,
t2=<optimized out>) at ../../gcc/gcc/gimple.c:3345
#2  gimple_types_compatible_p_1 (t1=0x7ffff6feb000, t2=0x7ffff728f690,
p=0x10ea9dc, sccstack=0x7ffffffee068, sccstate=0x1118380, 
    sccstate_obstack=0x7ffffffee070) at ../../gcc/gcc/gimple.c:3554
#3  0x00000000005bea20 in gimple_types_compatible_p (t2=0x7ffff728f690,
t1=0x7ffff6feb000) at ../../gcc/gcc/gimple.c:3943
#4  gimple_type_eq (p1=0x7ffff6feb000, p2=0x7ffff728f690) at
../../gcc/gcc/gimple.c:4438
#5  0x0000000000b6f064 in htab_find_slot_with_hash (htab=0x7ffff727db60,
element=0x7ffff728f690, hash=1226149484, insert=INSERT)
    at ../../gcc/libiberty/hashtab.c:668
#6  0x00000000005b87d1 in gimple_register_type_1 (t=0x7ffff728f690,
registering_mv=<optimized out>) at ../../gcc/gcc/gimple.c:4473
#7  0x00000000005b8803 in gimple_register_type_1 (t=0x7ffff6fc1540,
registering_mv=<optimized out>) at ../../gcc/gcc/gimple.c:4470
#8  0x00000000004996d4 in uniquify_nodes (data_in=0x10bb2b0, from=236) at
../../gcc/gcc/lto/lto.c:742
#9  0x0000000000499b13 in lto_read_decls (decl_data=0x7ffff73bf000,
data=0x7ffff718e020, resolutions=<optimized out>) at
../../gcc/gcc/lto/lto.c:933
#10 0x000000000049ab80 in lto_file_finalize (file_data=0x7ffff73bf000,
file=<optimized out>) at ../../gcc/gcc/lto/lto.c:1173
#11 lto_create_files_from_ids (count=<synthetic pointer>,
file_data=0x7ffff73bf000, file=0x1028eb0) at ../../gcc/gcc/lto/lto.c:1183
#12 lto_file_read (count=<synthetic pointer>, resolution_file=0x10b70b0,
file=0x1028eb0) at ../../gcc/gcc/lto/lto.c:1223
#13 read_cgraph_and_symbols (fnames=0x103ac10, nfiles=110) at
../../gcc/gcc/lto/lto.c:2624
#14 lto_main () at ../../gcc/gcc/lto/lto.c:2938
#15 0x00000000006f5b24 in compile_file () at ../../gcc/gcc/toplev.c:557
#16 do_compile () at ../../gcc/gcc/toplev.c:1935
#17 toplev_main (argc=173, argv=0x10130d0) at ../../gcc/gcc/toplev.c:2011
#18 0x00007ffff7895425 in __libc_start_main (main=0x49ea50 <main>, argc=64,
ubp_av=0x7fffffffdb58, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffdb48) at libc-start.c:226
#19 0

Reply via email to