-
-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing component multiple inheritance
- flyby: fixing get_ptr<>(sync)
- Loading branch information
Showing
4 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
# Copyright (c) 2020-2021 The STE||AR-Group | ||
# Copyright (c) 2022 Hartmut Kaiser | ||
# | ||
# SPDX-License-Identifier: BSL-1.0 | ||
# Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
set(tests multiple_inheritance_5964) | ||
|
||
foreach(test ${tests}) | ||
set(sources ${test}.cpp) | ||
|
||
source_group("Source Files" FILES ${sources}) | ||
|
||
set(folder_name "Tests/Regressions/Modules/Full/Components") | ||
|
||
# add example executable | ||
add_hpx_executable( | ||
${test}_test INTERNAL_FLAGS | ||
SOURCES ${sources} ${${test}_FLAGS} | ||
EXCLUDE_FROM_ALL | ||
FOLDER ${folder_name} | ||
) | ||
|
||
add_hpx_regression_test("modules.components" ${test} ${${test}_PARAMETERS}) | ||
endforeach() |
107 changes: 107 additions & 0 deletions
107
libs/full/components/tests/regressions/multiple_inheritance_5964.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (c) 2022 Joseph Kleinhenz | ||
// | ||
// SPDX-License-Identifier: BSL-1.0 | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// This test illustrates the problem reported by #5964: component with multiple | ||
// inheritance | ||
|
||
#include <hpx/config.hpp> | ||
|
||
#if !defined(HPX_COMPUTE_DEVICE_CODE) | ||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/include/actions.hpp> | ||
#include <hpx/include/async.hpp> | ||
#include <hpx/include/components.hpp> | ||
#include <hpx/include/runtime.hpp> | ||
#include <hpx/include/util.hpp> | ||
#include <hpx/modules/testing.hpp> | ||
|
||
#include <atomic> | ||
#include <cstddef> | ||
#include <utility> | ||
#include <vector> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
struct foo_t | ||
{ | ||
int a; | ||
int b; | ||
|
||
foo_t() = default; | ||
foo_t(int a, int b) | ||
: a(a) | ||
, b(b) | ||
{ | ||
} | ||
|
||
friend class hpx::serialization::access; | ||
template <typename Archive> | ||
inline void serialize(Archive& ar, const unsigned int) | ||
{ | ||
// clang-format off | ||
ar & a & b; | ||
// clang-format on | ||
} | ||
}; | ||
|
||
struct component_server | ||
: hpx::components::component_base<component_server> | ||
, foo_t | ||
{ | ||
explicit component_server(foo_t foo) | ||
: foo_t(std::move(foo)) | ||
{ | ||
} | ||
}; | ||
|
||
HPX_REGISTER_COMPONENT( | ||
hpx::components::component<component_server>, component_server_component) | ||
|
||
struct component_server2 | ||
: foo_t | ||
, hpx::components::component_base<component_server2> | ||
|
||
{ | ||
explicit component_server2(foo_t foo) | ||
: foo_t(std::move(foo)) | ||
{ | ||
} | ||
}; | ||
|
||
HPX_REGISTER_COMPONENT( | ||
hpx::components::component<component_server2>, component_server2_component) | ||
|
||
int hpx_main() | ||
{ | ||
foo_t in{1, 2}; | ||
|
||
{ | ||
hpx::id_type id = | ||
hpx::new_<component_server>(hpx::find_here(), in).get(); | ||
auto out = hpx::get_ptr<component_server>(hpx::launch::sync, id); | ||
|
||
HPX_TEST_EQ(out->a, in.a); | ||
HPX_TEST_EQ(out->b, in.b); | ||
} | ||
|
||
{ | ||
hpx::id_type id = | ||
hpx::new_<component_server2>(hpx::find_here(), in).get(); | ||
auto out = hpx::get_ptr<component_server2>(hpx::launch::sync, id); | ||
|
||
HPX_TEST_EQ(out->a, in.a); | ||
HPX_TEST_EQ(out->b, in.b); | ||
} | ||
|
||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
HPX_TEST_EQ(hpx::init(argc, argv), 0); | ||
return hpx::util::report_errors(); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters