]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix type-erasure in experimental::net::executor (PR 94203)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 18 Mar 2020 00:23:39 +0000 (00:23 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 18 Mar 2020 00:23:39 +0000 (00:23 +0000)
commit98f29f5638f73d8e55590eba8098a537ba746287
tree9989825d505ad09d40b1c7f23c3730c4564d2920
parent3b2cc34369ae1a774f0c910454999613c320bfe6
libstdc++: Fix type-erasure in experimental::net::executor (PR 94203)

The _Tgt and _TgtImpl types that implement type-erasure didn't agree on
the virtual interface, so failed as soon as they were instantiated. With
Clang they failed even sooner. The interface was also dependent on
whether RTTI was enabled or not.

This patch fixes the broken virtual functions and makes the type work
without RTTI, by using a pointer to a specialization of a function
template (similar to the approaches in std::function and std::any).

The changes to the virtual functions would be an ABI change, except that
the previous code didn't even compile if instantiated. This is
experimental TS material anyway.

PR libstdc++/94203
* include/experimental/executor (executor::executor(Executor)): Call
make_shared directly instead of _M_create. Create _Tgt1 object.
(executor::executor(allocator_arg_t, const ProtoAlloc&, Executor)):
Call allocate_shared directly instead of _M_create. Create _Tgt2
object.
(executor::target_type): Add cast needed for new _Tgt interface.
(executor::target): Define when RTTI is disabled. Use _Tgt::_M_func.
(executor::_Tgt): Define the same interface whether RTTI is enabled or
not.
(executor::_Tgt::target_type, executor::_Tgt::target): Do not use
std::type_info in the interface.
(executor::_Tgt::_M_func): Add data member.
(executor::_TgtImpl): Replace with _Tgt1 and _Tgt2 class templates.
(executor::_Tgt1::_S_func): Define function to access target without
depending on RTTI.
(executor::_M_create): Remove.
(operator==, operator!=): Simplify comparisons for executor.
* include/experimental/socket (is_error_code_enum<socket_errc>):
Define specialization before use.
* testsuite/experimental/net/executor/1.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/executor
libstdc++-v3/include/experimental/socket
libstdc++-v3/testsuite/experimental/net/executor/1.cc [new file with mode: 0644]
This page took 0.067493 seconds and 5 git commands to generate.