I want to have a GTY() garbage collected structure such that, when it is destoyed, some specific routine is called (this should indeed be possible, since GGC is a mark& sweep garbage collector, which delet individually each dead data).
if_marked and deletable are not what you want; they are two different kinds of "weak pointer" (as it is usually called in the literature). GGC doesn't have weak pointers in the general case, just these two special varieties. We definitely don't have the feature you want now, and I would be very hesitant to try to add it - the existing sweep phase is quite lazy, and I'd really prefer not to do anything that made it harder to switch to a more efficient collector algorithm. On the other hand, I sympathize with your goal; I've been idly thinking a little myself about the sensibility of using MPFR throughout, instead of our bespoke REAL_VALUE_TYPE thing. [I don't know if this is actually a good idea yet.] So my question to you is, what do those destruction routines do, and is are they actually a necessary thing if the memory has been allocated by GGC rather than library-internal calls to malloc()? Take note that you can NOT have pointers from GGC memory to malloc arena, without very special handling that should not be written unless there is no alternative. Thus, if the library habitually gives back pointers to malloc memory, you're going to have to get it to stop somehow. For MPFR, have a look at the mpfr_custom_* interface; for PPL, you're on your own (I am opposed on principle to the use of C++ in GCC core, including via external libraries). zw