Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2021-09-29 13:17:56


On 9/29/21 1:24 PM, rajesh daggumati via Boost wrote:
> HI Team,
> // i have caught exception in exception_ptr and I and trying to convert to
> ExceptionPtr_t

What is ExceptionPtr_t?

Assuming it is a shared_ptr, as can be guessed from the title, you can't
convert exception_ptr to shared_ptr (or any other smart-pointer) without
copying the exception object.

> but I am facing issue at below derived->severity().
> * unknown file: error: SEH exception with code 0xc0000005 thrown in the
> test body.*
>
> *code snippet is :*
> *E*xceptionPtr_t ExceptionHelper::TryGetExceptionPtr(boost::exception_ptr
> exception)
> {
> ExceptionPtr_t result ;
> std::string res;
> if(!exception) return result;
> try
> {
> boost::rethrow_exception(exception)
> *}catch(boost::exception &e)*
>
> *{boost::throw_file::value_type const* throw_file_data =
> boost::get_error_info<boost::throw_file>(e);*
> *if(* *throw_file_data)*
> *{*
> * result = exceptionPtr_t(new
> ExceptionWrapper(exception,*throw_filed_data,true))*
> *}*
> *return result;*
>
> *}*
>
> I was doing like:
>
> const Exception* derived = reinterPret_cast<const Exception*>
> (&exception)// here exception is type of exception_ptr

You've been pointed to this being incorrect before:

https://lists.boost.org/Archives/boost/2021/09/251987.php

You're just accessing memory through an invalid pointer and getting an
access violation.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk