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



--- Comment #11 from Diego Novillo <dnovillo at gcc dot gnu.org> 2013-01-07 
17:54:14 UTC ---

(In reply to comment #9)

> Eh.  Diego, how does GTY((user)) work here?  It smells like a bug in vec.h

> to me.

> 

> /* Garbage collection support for vec<T, A, vl_embed>.  */

> 

> template<typename T>

> void

> gt_ggc_mx (vec<T, va_gc> *v)

> {

>   extern void gt_ggc_mx (T &);

>   for (unsigned i = 0; i < v->length (); i++)

>     gt_ggc_mx ((*v)[i]);

> }

> 

> doesn't it need to mark the vec itself?  Maybe automatic registration of

> roots (this is a GC root) does not work with GTY((user))?



No.  The root is/should be marked by the code calling gt_ggc_mx.  gengtype will

generate code like:



  if (ggc_test_and_set_mark (x))

    {

      gt_ggc_mx (x);

    }



ggc_test_and_set_mark() is the one that marks the root.  Has gengtype generated

a function for this global?  It should be something like this



void

gt_ggc_mx_vec_<mangled_type_name> (void *x_p)

{

  vec<type_name,va_gc> * const x = (vec<type_name,va_gc> *)x_p;

  if (ggc_test_and_set_mark (x))

    {

      gt_ggc_mx (x);

    }

}

Reply via email to