Alexandre Duret-Lutz wrote: > The manual states that user-defined %destructors are called only on a > specific list of discarded symbols: > > [...]
Akim can hopefully better answer your questions about "%destructor" implementation, but concerning your concrete issues: I'd recommend when using variants, to avoid using "%destructor" at all and instead use proper RAII types (i.e. with their own C++ destructors and copy and/or move constructors/assignments as appropriate). In your application, std::unique_ptr or std::shared_ptr, both possibly with a custom deleter, may do the trick; otherwise you can implement a custom class with those semantics. In my experience, that's enough to make sure values are destructed exactly when they should. (If not, I'd consider this a bug to be reported.) In particular, if you move the semantic values in your actions, it's true $1 etc. will be destructed afterwards, but they'll typically contain empty (moved-from) states then. (If you need pre-C++11 support, it's more work; basically you'll have to implement move-semantics of your own and make sure to call them correctly.) To this end, you might find automove interesting (see http://www.gnu.org/software/bison/manual/html_node/_0025define-Summary.html). Regards, Frank