Re: [PATCH Coroutines]Insert the default return_void call at correct position

2020-02-27 Thread Nathan Sidwell

On 2/3/20 12:55 AM, bin.cheng wrote:

Hi,

Exception in coroutine is not correctly handled because the default
return_void call is now inserted before the finish suspend point,
rather than at the end of the original coroutine body.  This patch
fixes the issue by generating following code:
   co_await promise.initial_suspend();
   try {
 // The original coroutine body

 promise.return_void(); // The default return_void call.
   } catch (...) {
 promise.unhandled_exception();
   }
   final_suspend:
   // ...

Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin

gcc/cp
2020-02-03  Bin Cheng  

 * coroutines.cc (build_actor_fn): Factor out code inserting the
 default return_void call to...
 (morph_fn_to_coro): ...here, also hoist local var declarations.

gcc/testsuite
2020-02-03  Bin Cheng  

 * g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.


ok, thanks!

nathan

--
Nathan Sidwell


Re: [PATCH Coroutines]Insert the default return_void call at correct position

2020-02-13 Thread Iain Sandoe

Hello Bin, Nathan,

Iain Sandoe  wrote:



We are seeking to clarify the standard wording around this (and the cases  
where
unhandled_exception() returns - hopefully during the WG21 meeting this  
week,


FWIW, I think your interpretation makes sense here.


It’s not clear if the committee will have time to process wording changes  
needed for this during the current session, however, it is agreed that  
injecting the return_void at the closing brace of the user’s original  
function (your solution) is the correct approach.


So, from my point of view this patch DTRT and should be applied,

thanks
Iain



Thanks,
bin

On Mon, Feb 3, 2020 at 1:55 PM bin.cheng   
wrote:

Hi,

Exception in coroutine is not correctly handled because the default
return_void call is now inserted before the finish suspend point,
rather than at the end of the original coroutine body.  This patch
fixes the issue by generating following code:
co_await promise.initial_suspend();
try {
 // The original coroutine body

 promise.return_void(); // The default return_void call.
} catch (...) {
 promise.unhandled_exception();
}
final_suspend:
// ...

Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin

gcc/cp
2020-02-03  Bin Cheng  

 * coroutines.cc (build_actor_fn): Factor out code inserting the
 default return_void call to...
 (morph_fn_to_coro): ...here, also hoist local var declarations.

gcc/testsuite
2020-02-03  Bin Cheng  

 * g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.





Re: [PATCH Coroutines]Insert the default return_void call at correct position

2020-02-10 Thread Iain Sandoe
Hi Bin,

Bin.Cheng  wrote:

> Ping.

We are seeking to clarify the standard wording around this (and the cases where
unhandled_exception() returns - hopefully during the WG21 meeting this week,

FWIW, I think your interpretation makes sense here.

thanks
Iain

> 
> Thanks,
> bin
> 
> On Mon, Feb 3, 2020 at 1:55 PM bin.cheng  wrote:
>> Hi,
>> 
>> Exception in coroutine is not correctly handled because the default
>> return_void call is now inserted before the finish suspend point,
>> rather than at the end of the original coroutine body.  This patch
>> fixes the issue by generating following code:
>>  co_await promise.initial_suspend();
>>  try {
>>// The original coroutine body
>> 
>>promise.return_void(); // The default return_void call.
>>  } catch (...) {
>>promise.unhandled_exception();
>>  }
>>  final_suspend:
>>  // ...
>> 
>> Bootstrap and test on x86_64.  Is it OK?
>> 
>> Thanks,
>> bin
>> 
>> gcc/cp
>> 2020-02-03  Bin Cheng  
>> 
>>* coroutines.cc (build_actor_fn): Factor out code inserting the
>>default return_void call to...
>>(morph_fn_to_coro): ...here, also hoist local var declarations.
>> 
>> gcc/testsuite
>> 2020-02-03  Bin Cheng  
>> 
>>* g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.




Re: [PATCH Coroutines]Insert the default return_void call at correct position

2020-02-10 Thread Bin.Cheng
Ping.

Thanks,
bin

On Mon, Feb 3, 2020 at 1:55 PM bin.cheng  wrote:
>
> Hi,
>
> Exception in coroutine is not correctly handled because the default
> return_void call is now inserted before the finish suspend point,
> rather than at the end of the original coroutine body.  This patch
> fixes the issue by generating following code:
>   co_await promise.initial_suspend();
>   try {
> // The original coroutine body
>
> promise.return_void(); // The default return_void call.
>   } catch (...) {
> promise.unhandled_exception();
>   }
>   final_suspend:
>   // ...
>
> Bootstrap and test on x86_64.  Is it OK?
>
> Thanks,
> bin
>
> gcc/cp
> 2020-02-03  Bin Cheng  
>
> * coroutines.cc (build_actor_fn): Factor out code inserting the
> default return_void call to...
> (morph_fn_to_coro): ...here, also hoist local var declarations.
>
> gcc/testsuite
> 2020-02-03  Bin Cheng  
>
> * g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.


[PATCH Coroutines]Insert the default return_void call at correct position

2020-02-02 Thread bin.cheng
Hi,

Exception in coroutine is not correctly handled because the default
return_void call is now inserted before the finish suspend point,
rather than at the end of the original coroutine body.  This patch
fixes the issue by generating following code:
  co_await promise.initial_suspend();
  try {
// The original coroutine body

promise.return_void(); // The default return_void call.
  } catch (...) {
promise.unhandled_exception();
  }
  final_suspend:
  // ...

Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin

gcc/cp
2020-02-03  Bin Cheng  

* coroutines.cc (build_actor_fn): Factor out code inserting the
default return_void call to...
(morph_fn_to_coro): ...here, also hoist local var declarations.

gcc/testsuite
2020-02-03  Bin Cheng  

* g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.

0001-Insert-default-return_void-at-the-end-of-coroutine-b.patch
Description: Binary data