This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
make_node vs. copy_node
- To: gcc at gcc dot gnu dot org
- Subject: make_node vs. copy_node
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 12 Aug 1999 12:45:30 -0700
- Organization: CodeSourcery, LLC
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