diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-05-26 08:57:32 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2020-05-26 12:27:48 +0100 |
commit | f6615c213354fd3ec7fc6238e61cc26bb1830464 (patch) | |
tree | da7fa87ac3cace0696ca8bad889960f7ccd42abd /gcc | |
parent | c8462662da25f2cb8de0e4fe82ec5880041f38f2 (diff) | |
download | gcc-f6615c213354fd3ec7fc6238e61cc26bb1830464.zip gcc-f6615c213354fd3ec7fc6238e61cc26bb1830464.tar.gz gcc-f6615c213354fd3ec7fc6238e61cc26bb1830464.tar.bz2 |
coroutines, testsuite: Fix co-ret-17-void-ret-coro.C.
This was a bad testcase, found with fsanitize=address; the final suspend
is 'suspend never' which flows off the end of the coroutine destroying
the promise and the frame. At that point access via the handle is an
error. Fixed by checking that the promise is destroyed via a global var.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C: Check for
promise destruction via a global variable.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C b/gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C index 3168ea2..01a75c1 100644 --- a/gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C +++ b/gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C @@ -5,14 +5,17 @@ #include "../coro.h" +int g_promise = -1; + template<typename R, typename HandleRef, typename ...T> struct std::coroutine_traits<R, HandleRef, T...> { struct promise_type { promise_type (HandleRef h, T ...args) { h = std::coroutine_handle<promise_type>::from_promise (*this); PRINT ("Created Promise"); + g_promise = 1; } - + ~promise_type () { PRINT ("Destroyed Promise"); g_promise = 0;} void get_return_object() {} auto initial_suspend() { @@ -45,10 +48,11 @@ int main () // initial suspend. h.resume (); - - if (!h.done()) + + // The coro should have self-destructed. + if (g_promise) { - PRINT ("main: apparently wasn't done..."); + PRINT ("main: apparently we did not complete..."); abort (); } |