[PATCH] Come up with constructors of symtab_node, cgraph_node and varpool_node.

Martin Liška mliska@suse.cz
Thu Dec 5 13:04:00 GMT 2019


On 12/5/19 1:59 PM, Richard Biener wrote:
> Isn't there ggc_alloc <T> for this?  Also ggc_alloc_no_dtor<T> in case you
> want to handle finalization yourself.

No, if I see correctly it only calls Dtor:

template<typename T>
inline T *
ggc_alloc (ALONE_CXX_MEM_STAT_INFO)
{
   if (need_finalization_p<T> ())
     return static_cast<T *> (ggc_internal_alloc (sizeof (T), finalize<T>, 0, 1
						 PASS_MEM_STAT));
   else
     return static_cast<T *> (ggc_internal_alloc (sizeof (T), NULL, 0, 1
						 PASS_MEM_STAT));
}

...

/* Allocate a chunk of memory of SIZE bytes.  Its contents are undefined.  */

void *
ggc_internal_alloc (size_t size, void (*f)(void *), size_t s, size_t n
		    MEM_STAT_DECL)
{
...

The function is generic, it does not know about type T. That's why it
does not (and can't call) ctor.

Martin



More information about the Gcc-patches mailing list