Skip to content

Commit

Permalink
🚨 fix C4100 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Aug 13, 2021
1 parent 288cdf9 commit 4b0e04e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 1 addition & 4 deletions test/src/unit-allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ struct my_allocator : std::allocator<T>
std::allocator<T>::deallocate(p, n);
}

// the code below warns about p in MSVC 2015 - this could be a bug
DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
DOCTEST_MSVC_SUPPRESS_WARNING(4100)
void destroy(T* p)
{
if (next_destroy_fails)
Expand All @@ -111,9 +108,9 @@ struct my_allocator : std::allocator<T>
throw std::bad_alloc();
}

static_cast<void>(p); // fix MSVC's C4100 warning
p->~T();
}
DOCTEST_MSVC_SUPPRESS_WARNING_POP

template <class U>
struct rebind
Expand Down
11 changes: 4 additions & 7 deletions test/src/unit-udt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,24 +809,21 @@ TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated
static_assert(!is_constructible_patched<json, incomplete>::value, "");
}

// the code below warns about t in MSVC 2015 - this could be a bug
DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
DOCTEST_MSVC_SUPPRESS_WARNING(4100)

namespace
{
class Evil
{
public:
Evil() = default;
template <typename T>
Evil(T t) : m_i(sizeof(t)) {}
Evil(T t) : m_i(sizeof(t))
{
static_cast<void>(t); // fix MSVC's C4100 warning
}

int m_i = 0;
};

DOCTEST_MSVC_SUPPRESS_WARNING_POP

void from_json(const json& /*unused*/, Evil& /*unused*/) {}
} // namespace

Expand Down

0 comments on commit 4b0e04e

Please sign in to comment.