Skip to content

Commit 9c333f9

Browse files
authored
Fix recursive generator in msvc (#58)
* Slightly change recursive_generator_tests to evade MS bug See https://developercommunity.visualstudio.com/t/MSVC-generates-segfaulting-code-for-coro/10074712#T-ND10094725
1 parent 166688c commit 9c333f9

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

test/recursive_generator_tests.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,6 @@ TEST_CASE("exception thrown from recursive call can be caught by caller")
247247

248248
TEST_CASE("exceptions thrown from nested call can be caught by caller")
249249
{
250-
#if _MSC_VER >= 1929 && _MSVC_LANG == 202002L
251-
/*
252-
* Crashes. Known bug, reported in
253-
* https://github.com/andreasbuhr/cppcoro/issues/53
254-
* and
255-
* https://developercommunity.visualstudio.com/t/MSVC-generates-segfaulting-code-for-coro/10074712
256-
*/
257-
return;
258-
#endif
259-
260250
class SomeException : public std::exception {};
261251

262252
auto f = [](std::uint32_t depth, auto&& f) -> recursive_generator<std::uint32_t>
@@ -271,7 +261,8 @@ TEST_CASE("exceptions thrown from nested call can be caught by caller")
271261

272262
try
273263
{
274-
co_yield f(4, f);
264+
auto next_generator = f(4, f);
265+
co_yield next_generator;
275266
}
276267
catch (SomeException)
277268
{
@@ -286,7 +277,8 @@ TEST_CASE("exceptions thrown from nested call can be caught by caller")
286277
bool caught = false;
287278
try
288279
{
289-
co_yield f(3, f);
280+
auto next_generator = f(3, f);
281+
co_yield next_generator;
290282
}
291283
catch (SomeException)
292284
{
@@ -301,8 +293,10 @@ TEST_CASE("exceptions thrown from nested call can be caught by caller")
301293
else
302294
{
303295
co_yield 1;
304-
co_yield f(2, f);
305-
co_yield f(3, f);
296+
auto next_generator = f(2, f);
297+
co_yield next_generator;
298+
auto next_generator2 = f(3, f);
299+
co_yield next_generator2;
306300
}
307301
};
308302

0 commit comments

Comments
 (0)