Skip to content

Commit

Permalink
Fix unreachable warning (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhor authored Jan 24, 2020
1 parent fd6d99e commit af09372
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/wiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,7 +2494,8 @@ TEST_CASE("WindowsInternalTests::InitOnceNonTests")
init = {};

// A thrown exception leaves the object un-initialized
REQUIRE_THROWS_AS(winner = wil::init_once(init, [&] { called = true; throw wil::ResultException(E_FAIL); }), wil::ResultException);
static volatile bool always_true = true; // So that the compiler can't determine that we unconditionally throw below (warning C4702)
REQUIRE_THROWS_AS(winner = wil::init_once(init, [&] { called = true; THROW_HR_IF(E_FAIL, always_true); }), wil::ResultException);
REQUIRE_FALSE(wil::init_once_initialized(init));
REQUIRE(called);
REQUIRE_FALSE(winner);
Expand Down

0 comments on commit af09372

Please sign in to comment.