|
From: | Aurelian Melinte |
Subject: | Re: RAII techniques in semantic actions leading to double deletion |
Date: | Wed, 05 Dec 2012 19:51:27 -0500 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.9) Gecko/20100722 Eudora/3.0.4 |
On 05/12/2012 3:43 PM, John Horigan wrote:
Can I solve the problem by changing all of my auto_ptr<> declarations from this: exp_ptr mod($2); to this: exp_ptr mod($2); $2 = 0; to explicitly move ownership from the semantic value stack to my auto_ptr<>? Would this actually do what I think it does and can I still use @2 after erasing $2?
I am surprised you did not run immediately into double delete problems without exceptions. Do you have leaks if not using auto_ptr?
I am not knowledgeable of the inner workings of that skeleton but I think that, since the parser is the one that created the token, then the parser is in control of its lifetime and it guarantees the availability. The parser should own it, in particular because it has to be able to backtrack.
Regards, a.
[Prev in Thread] | Current Thread | [Next in Thread] |