Skip to content

Commit

Permalink
ignore warning for some strange gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed May 31, 2024
1 parent 09e6e3f commit c886e65
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
19 changes: 11 additions & 8 deletions example/use-with-bthread/bthread_graph_executor.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#include "bthread_graph_executor.h"
#include "butex_interface.h"

#include "babylon/logging/interface.h"

#include "butex_interface.h"

#include <tuple>

BABYLON_NAMESPACE_BEGIN
namespace anyflow {

static void* execute_invoke_vertex(void* args) {
auto param = reinterpret_cast<::std::tuple<GraphVertex*, GraphVertexClosure>*>(args);
auto vertex = ::std::get<0>(*param);
auto& closure = ::std::get<1>(*param);
vertex->run(::std::move(closure));
delete param;
return NULL;
auto param =
reinterpret_cast<::std::tuple<GraphVertex*, GraphVertexClosure>*>(args);
auto vertex = ::std::get<0>(*param);
auto& closure = ::std::get<1>(*param);
vertex->run(::std::move(closure));
delete param;
return NULL;
}

static void* execute_invoke_closure(void* args) {
auto param =
reinterpret_cast<::std::tuple<ClosureContext*, Closure::Callback*>*>(args);
reinterpret_cast<::std::tuple<ClosureContext*, Closure::Callback*>*>(
args);
auto closure = ::std::get<0>(*param);
auto callback = ::std::get<1>(*param);
closure->run(callback);
Expand Down
8 changes: 4 additions & 4 deletions src/babylon/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ inline ::std::unique_ptr<T> Any::release() noexcept {
}

auto pointer_value = _holder.pointer_value;
new (this) Any {};
return ::std::unique_ptr<T> {static_cast<T*>(pointer_value)};
new (this) Any;
return {static_cast<T*>(pointer_value), {}};
}

inline ::std::unique_ptr<void, void (*)(void*)> Any::release(
Expand All @@ -461,7 +461,7 @@ inline ::std::unique_ptr<void, void (*)(void*)> Any::release(
}

auto pointer_value = _holder.pointer_value;
new (this) Any {};
new (this) Any;
return {pointer_value, descriptor->deleter};
}

Expand All @@ -474,7 +474,7 @@ inline ::std::unique_ptr<void, void (*)(void*)> Any::release(
if (type_name == instance_type().name) {
auto pointer_value = _holder.pointer_value;
auto deleter = _meta.descriptor()->deleter;
new (this) Any {};
new (this) Any;
return {pointer_value, deleter};
}

Expand Down
10 changes: 10 additions & 0 deletions test/test_any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,10 @@ TEST_F(AnyTest, release_empty_get_nullptr) {
ASSERT_EQ(nullptr, any.release("AnyTest::NormalClass"));
}

#pragma GCC diagnostic push
#if BABYLON_GCC_VERSION >= 120100 && BABYLON_GCC_VERSION < 120300
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
#endif // BABYLON_GCC_VERSION >= 120100 && BABYLON_GCC_VERSION < 120300
TEST_F(AnyTest, release_wrong_type_get_nullptr_and_keep_instance_inside) {
auto descriptor = Any::descriptor<NormalClass>();
Any any(::std::string {"10086"});
Expand All @@ -1075,7 +1079,12 @@ TEST_F(AnyTest, release_wrong_type_get_nullptr_and_keep_instance_inside) {
ASSERT_EQ(nullptr, any.release("AnyTest::NormalClass"));
ASSERT_EQ("10086", *any.get<::std::string>());
}
#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#if BABYLON_GCC_VERSION >= 120100 && BABYLON_GCC_VERSION < 120300
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
#endif // BABYLON_GCC_VERSION >= 120100 && BABYLON_GCC_VERSION < 120300
TEST_F(AnyTest, release_reference_get_nullptr_and_keep_reference_inside) {
auto descriptor = Any::descriptor<NormalClass>();
Any any(::std::string {"10086"});
Expand All @@ -1084,6 +1093,7 @@ TEST_F(AnyTest, release_reference_get_nullptr_and_keep_reference_inside) {
ASSERT_EQ(nullptr, any.release("AnyTest::NormalClass"));
ASSERT_EQ("10086", *any.get<::std::string>());
}
#pragma GCC diagnostic pop

TEST_F(AnyTest, release_inplace_get_nullptr_and_keep_inplace_inside) {
{
Expand Down

0 comments on commit c886e65

Please sign in to comment.