Skip to content

Commit

Permalink
Fix MSVC warnings
Browse files Browse the repository at this point in the history
A couple of warnings have slipped in when compiling with MSVC, so let's squish 'em.

We still get a ton of "C4702 unreachable code" warnings when compiling with optimisation, but these all seem completely spurious.
  • Loading branch information
tcbrindle committed Jul 26, 2023
1 parent 87b50c5 commit 7f8b95c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions include/flux/core/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ struct assert_fn {
constexpr void operator()(bool cond, char const* msg,
std::source_location loc = std::source_location::current()) const
{
if (cond) [[likely]] {
if (cond) {
return;
} else [[unlikely]] {
} else {
runtime_error(msg, std::move(loc));
}
}
Expand Down
24 changes: 15 additions & 9 deletions include/flux/op/set_adaptors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ struct set_symmetric_difference_adaptor
flux::read_at(self.base2_, cur.base2_cursor))) {
cur.state_ = cursor_type::first;
return;
}
else {
} else {
if(std::invoke(self.cmp_, flux::read_at(self.base2_, cur.base2_cursor),
flux::read_at(self.base1_, cur.base1_cursor))) {
cur.state_ = cursor_type::second;
Expand Down Expand Up @@ -366,9 +365,13 @@ struct set_symmetric_difference_adaptor
-> std::common_reference_t<decltype(flux::read_at(self.base1_, cur.base1_cursor)),
decltype(flux::read_at(self.base2_, cur.base2_cursor))>
{
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done)
return flux::read_at(self.base1_, cur.base1_cursor);
return flux::read_at(self.base2_, cur.base2_cursor);
using R = std::common_reference_t<decltype(flux::read_at(self.base1_, cur.base1_cursor)),
decltype(flux::read_at(self.base2_, cur.base2_cursor))>;
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done) {
return static_cast<R>(flux::read_at(self.base1_, cur.base1_cursor));
} else {
return static_cast<R>(flux::read_at(self.base2_, cur.base2_cursor));
}
}

template <typename Self>
Expand All @@ -384,11 +387,14 @@ struct set_symmetric_difference_adaptor
-> std::common_reference_t<decltype(flux::move_at(self.base1_, cur.base1_cursor)),
decltype(flux::move_at(self.base2_, cur.base2_cursor))>
{
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done)
return flux::move_at(self.base1_, cur.base1_cursor);
return flux::move_at(self.base2_, cur.base2_cursor);
using R = std::common_reference_t<decltype(flux::move_at(self.base1_, cur.base1_cursor)),
decltype(flux::move_at(self.base2_, cur.base2_cursor))>;
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done) {
return static_cast<R>(flux::move_at(self.base1_, cur.base1_cursor));
} else {
return static_cast<R>(flux::move_at(self.base2_, cur.base2_cursor));
}
}

};
};

Expand Down
4 changes: 2 additions & 2 deletions test/test_repeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ constexpr bool test_repeat()
// Check that internal iteration works as expected
{
auto counter = 0;
auto cur =
auto inner_cur =
flux::for_each_while(seq, [&](int) { return counter++ < 5; });
STATIC_CHECK(cur == 5);
STATIC_CHECK(inner_cur == 5);
}
}

Expand Down

0 comments on commit 7f8b95c

Please sign in to comment.