I tried to return the error of a result<int> in a result<void>, which lead to a segmentation fault while cloning the error. It occurred in the call system_error2::detail::indirecting_domain<system_error2::status_code<_file_io_error_domain> >::_do_erased_copy.
Executing the binary leads to the following segmentation fault:
Program received signal SIGSEGV, Segmentation fault.
0x0000555555556ed6 in system_error2::status_code_domain::operator== (this=0x0, o=...) at ../../../include/outcome/experimental/status-code/include/status_code_domain.hpp:372
372 constexpr bool operator==(const status_code_domain &o) const noexcept { return _id == o._id; }
(gdb) where
#0 0x0000555555556ed6 in system_error2::status_code_domain::operator== (this=0x0, o=...) at ../../../include/outcome/experimental/status-code/include/status_code_domain.hpp:372
#1 0x000055555555aa81 in system_error2::detail::indirecting_domain<system_error2::status_code<_file_io_error_domain> >::_do_erased_copy (
this=0x555555561ac0 <system_error2::detail::_indirecting_domain<system_error2::status_code<_file_io_error_domain> >>, dst=..., src=...) at ../../../include/outcome/experimental/status-code/include/status_code_ptr.hpp:100
#2 0x000055555555906e in system_error2::status_code<system_error2::erased<long, true> >::clone (this=0x7fffffffdc38) at ../../../include/outcome/experimental/status-code/include/status_code.hpp:457
#3 0x000055555555650b in test () at experimental_status_code.cpp:226
#4 0x00005555555565b5 in main () at experimental_status_code.cpp:233
A status_code without a indirecting_domain can be cloned without the segmentation fault, as they are only copied using memcpy().
Maybe I'm doing this completely wrong. In this case I would be happy, if you could give me a hint, on how to return a status_code from result<int> in a result<void>.
I have modified the example doc/src/snippets/experimental_status_code.cpp to https://godbolt.org/z/-vGZnm.
I tried to return the error of a
result<int>
in aresult<void>
, which lead to a segmentation fault while cloning the error. It occurred in the callsystem_error2::detail::indirecting_domain<system_error2::status_code<_file_io_error_domain> >::_do_erased_copy
.Executing the binary leads to the following segmentation fault:
A status_code without a indirecting_domain can be cloned without the segmentation fault, as they are only copied using memcpy().
Maybe I'm doing this completely wrong. In this case I would be happy, if you could give me a hint, on how to return a status_code from
result<int>
in aresult<void>
.