id summary reporter owner description type status milestone component version severity resolution keywords cc 8268 basic_hold_any missing assignment operator Matthew South Joel de Guzman "Self contatined repro: struct Big { int x[ 4 ]; }; (big enough to prevent the small optimisation in hold_any) { boost::spirit::hold_any sourceAny = boost::spirit::hold_any( Big() ); boost::spirit::hold_any copyInto; copyInto = sourceAny; (calls a compiler generated assignment operator which copies the address of the memory allocated in sourceAny) } // CRASH: double deletion of the heap allocated Big held in sourceAny as both copyInto // and sourceAny go out of scope The problem is that the assignment operator provided in basic_hold_any doesn't suppress the compiler generated one because it is a template function, and the compiler generator one only does a shallow copy. The relevant section in the C++ standard is N3485 §12.18: ""A user-declared copy assignment operator X::operator= is a non-static non-template member function of class X with exactly one parameter of type X, X&, const X&, volatile X& or const volatile X&. (121)"" ""(121) Because a template assignment operator or an assignment operator taking an rvalue reference parameter is never a copy assignment operator, the presence of such an assignment operator does not suppress the implicit declaration of a copy assignment operator. Such assignment operators participate in overload resolution with other assignment operators, including copy assignment operators, and, if selected, will be used to assign an object."" To fix this issue, simply add the non-template assignment constructor to basic_hold_any: // assignment operator basic_hold_any& operator=(basic_hold_any const& x) { return assign(x); }" Bugs closed To Be Determined spirit Boost Development Trunk Problem fixed hold_any