[spirit] hold_any invalid assignment to destructed object?

Hi,
The boost::spirit::hold_any implementation includes the following functions
defined in the detail sub-namespace:
// member of fxnsmpl::true_ specialisation, line 99
static void move(void* const* src, void** dest)
{
reinterpret_cast

The boost::spirit::hold_any implementation includes the following functions defined in the detail sub-namespace:
// member of fxnsmpl::true_ specialisation, line 99 static void move(void* const* src, void** dest) { reinterpret_cast
(dest)->~T(); *reinterpret_cast (dest) = *reinterpret_cast (src); } // member of fxnsmpl::false_ specialisation, line 99 static void move(void* const* src, void** dest) { (*reinterpret_cast
(dest))->~T(); **reinterpret_cast (dest) = **reinterpret_cast (src); } As I understand it, the object is destroyed _and then assigned to_; does it not need to be constructed at this point, i.e. have something like this (for the first specialisation):
new (reinterpret_cast
(dest)) T( *reinterpret_cast (src) );
Yes, your code looks about right. Would you care to submit a patch for me to apply? Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu

On Tuesday, 12 March 2013 22:21:05 UTC, Hartmut Kaiser wrote:
*snip*
As I understand it, the object is destroyed _and then assigned to_; does it not need to be constructed at this point, i.e. have something like this (for the first specialisation):
new (reinterpret_cast
(dest)) T( *reinterpret_cast (src) ); Yes, your code looks about right. Would you care to submit a patch for me to apply?
Patch attached. After looking through the file in more depth it seemed more sensible to do away with the destruct-construct cycle and just assign directly. Thanks --rob

Thanks, I applied your patch to trunk. Regards Hartmut --------------- http://boost-spirit.com http://boost-spirit.com/ http://stellar.cct.lsu.edu From: Rob Desbois [mailto:rob.desbois@gmail.com] Sent: Wednesday, March 13, 2013 4:37 AM To: boost-devel-archive@googlegroups.com Cc: boost@lists.boost.org; boost@lists.boost.org; hartmut.kaiser@gmail.com Subject: Re: [boost] [spirit] hold_any invalid assignment to destructed object? On Tuesday, 12 March 2013 22:21:05 UTC, Hartmut Kaiser wrote:
*snip*
As I understand it, the object is destroyed _and then assigned to_; does it not need to be constructed at this point, i.e. have something like this (for the first specialisation):
new (reinterpret_cast
(dest)) T( *reinterpret_cast (src) );
Yes, your code looks about right. Would you care to submit a patch for me to apply? Patch attached. After looking through the file in more depth it seemed more sensible to do away with the destruct-construct cycle and just assign directly. Thanks --rob
participants (2)
-
Hartmut Kaiser
-
Rob Desbois