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]

make_node vs. copy_node



These two functions do not operate in the same way with respect to
obstacks.  In particular, make_node does things like this:

      /* All decls in an inline function need to be saved.  */
      if (obstack != &permanent_obstack)
	obstack = saveable_obstack;

whereas copy_node just blithely allocated on the current_obstack.
This has bad consequences if one does a copy_node on a decl in an
inline function.  (Why would one do this?  When instantiating a
template, for example; we copy the template decl and then modify it.)

I think that the semantics of copy_node should be roughly:

  new_node = make_node (code);
  memcpy (new_node, old_node, size);

Does anyone disagree?  (I don't propose literally doing this; the
example is only for clarity.)

Does anyone care to pre-approve a patch that replicates the obstack
handling of make_node, assuming the regression tests don't blow up?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


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