Skip to content

Commit

Permalink
chore: silence a few warnings
Browse files Browse the repository at this point in the history
-Wdynamic-class-memaccess and -Wunused-lambda-capture
  • Loading branch information
zhihaoy committed Dec 9, 2024
1 parent 7a08778 commit ac1e077
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/std23/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ template<class S, class R, class... Args> class function<S, R(Args...)>
explicit operator bool() const noexcept
{
constexpr empty_target_object null;
return __builtin_memcmp(storage_, &null, sizeof(void *)) != 0;
return __builtin_memcmp(storage_, (void *)&null, sizeof(void *)) != 0;
}

friend bool operator==(function const &f, nullptr_t) noexcept { return !f; }
Expand Down
7 changes: 4 additions & 3 deletions tests/function/test_ctad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ inline constexpr bool deduction_enabled = type_traits::is_valid<T>(
void test_ctad()
{
{
function fn = [i = 0] { return 0; };
function fn = [i = 0] { return i; };
static_assert(std::is_same_v<decltype(fn), function<int()>>);
static_assert(std::is_same_v<decltype(fn)::result_type, int>);
}

{
function fn = [i = 0](int &&, int const) mutable { return "lit"; };
function fn = [i = 0](int &&, int const) mutable
{ return (void)i, "lit"; };
static_assert(
std::is_same_v<decltype(fn), function<char const *(int &&, int)>>);
static_assert(std::is_same_v<decltype(fn)::result_type, char const *>);
Expand All @@ -27,7 +28,7 @@ void test_ctad()
}

{
function fn = [i = 0]() noexcept { return 0; };
function fn = [i = 0]() noexcept { return i; };
static_assert(std::is_same_v<decltype(fn), function<int()>>,
"[func.wrap.func.con]/16");
static_assert(std::is_same_v<decltype(fn)::result_type, int>);
Expand Down
2 changes: 1 addition & 1 deletion tests/function_ref/test_call_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ suite call_pattern = []
{
expect(fr() == some_str);

auto fn = [i = 0] { return some_str.data(); };
auto fn = [i = 0] { return (void)i, some_str.data(); };
fr = decltype(fr)(fn);

expect(fr() == some_str);
Expand Down
1 change: 1 addition & 0 deletions tests/move_only_function/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target_sources(run-move_only_function PRIVATE
"test_unique.cpp"
)
target_compile_options(run-move_only_function PRIVATE
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wno-self-move>
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-fsized-deallocation>)
target_link_libraries(run-move_only_function PRIVATE nontype_functional kris-ut)
set_target_properties(run-move_only_function PROPERTIES OUTPUT_NAME run)
Expand Down

0 comments on commit ac1e077

Please sign in to comment.