This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: enable-build-with-cxx bootstrap compare broken by r149964


On Tue, 2009-09-22 at 09:40 -0400, Jason Merrill wrote:
> On 09/22/2009 07:04 AM, Jerry Quinn wrote:
> > On Mon, 2009-09-21 at 13:06 -0400, Jason Merrill wrote:
> >> On 09/14/2009 11:54 AM, Jason Merrill wrote:
> >>> I think the way to go with this is to revert the compiler bits of
> >>> r149964, not mess with mangle.c at all, and insert the initial * if the
> >>> typeinfo name won't have TREE_PUBLIC set, since that's precisely the
> >>> property we want to mirror in comparison.
> >>
> >> Thoughts?  Another concern I have is that adding an initial * breaks
> >> simple demangling of type_info::name(), so I'd like to find another way
> >> of marking it for pointer comparison.
> >
> > What if we have type_info::name() be smart?  I.e.
> >
> > const char* name() { return name[0] == '*' ? name + 1 : name; }
> >
> > Then the * can still be a flag indicating compare by pointer.
> 
> I like it.

I'm trying the following in cp/rtti.c, but I get a segfault compiling 
testsuite/g++.dg/debug/dwarf2/pr41063.C

Removing the TREE_PUBLIC code fixes the segfault, so it's definitely
related.  I also tried using an arbitrary string for name_string, but I
get the same segfault.  It seems like something is expecting the name to
be exactly in synch with the decl.

I'm not really sure how everything fits together here.  Am I missing
something obvious?

tinfo_base_init (tinfo_s *ti, tree target)
{
  tree init = NULL_TREE;
  tree name_decl;
  tree vtable_ptr;

  {
    tree name_name;

    /* Generate the NTBS array variable.  */
    tree name_type = build_cplus_array_type
		     (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
		     NULL_TREE);
    tree name_string = tinfo_name (target);

    /* Determine the name of the variable -- and remember with which
       type it is associated.  */
    name_name = mangle_typeinfo_string_for_type (target);
    TREE_TYPE (name_name) = target;

    name_decl = build_lang_decl (VAR_DECL, name_name, name_type);
    SET_DECL_ASSEMBLER_NAME (name_decl, name_name);
    DECL_ARTIFICIAL (name_decl) = 1;
    DECL_IGNORED_P (name_decl) = 1;
    TREE_READONLY (name_decl) = 1;
    TREE_STATIC (name_decl) = 1;
    DECL_EXTERNAL (name_decl) = 0;
    DECL_TINFO_P (name_decl) = 1;
    set_linkage_according_to_type (target, name_decl);
    import_export_decl (name_decl);
    if (!TREE_PUBLIC (name_decl))
      {
    	/* Inject '*' at start of name to force pointer comparison.  */
    	int len = TREE_STRING_LENGTH (name_string);
    	char* buf = (char*) XNEWVEC (char, len + 1);
    	buf[0] = '*';
    	memcpy (buf + 1, TREE_STRING_POINTER (name_string), len);
    	name_string = build_string (len + 1, buf);
    	XDELETEVEC (buf);
      }
    DECL_INITIAL (name_decl) = name_string;
    mark_used (name_decl);
    pushdecl_top_level_and_finish (name_decl, name_string);
  }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]