[Bug c++/105104] [coroutines] ICE during GIMPLE pass: coro-early-expand-ifns

2022-04-18 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105104

Iain Sandoe  changed:

   What|Removed |Added

   Last reconfirmed|2022-03-30 00:00:00 |2022-4-18
 CC||iains at gcc dot gnu.org,
   ||jakub at gcc dot gnu.org
 Status|WAITING |NEW
   Keywords||ice-on-valid-code

--- Comment #6 from Iain Sandoe  ---
Initial analysis - perhaps some issue with constexpr processing:

When we have a void await_return() in  the final_awaiter class:

 final.suspend:
 frame_ptr->_Coro_resume_fn = 0B;
 {
 struct final_awaiter Fs [value-expr: frame_ptr->Fs_1_2];

 frame_ptr->_Coro_resume_index = 4;
 _15 = _ptr->_Coro_self_handle;
 D.9844 = std::__n4861::coroutine_handle::operator
std::__n4861::coroutine_handle (_15);
 return_object::promise_type::final_awaiter::await_suspend (D.9844);
 D.9768 = .CO_YIELD (4, 1, , , frame_ptr);
 retval.2 = D.9768;
 switch (retval.2) , case 0: , case 1: >
 :
 .CO_SUSPN ();
 :
 goto resume.4;
 :
 goto destroy.4;
 destroy.4:
 goto coro.delete.promise;
 resume.4:
 return_object::promise_type::final_awaiter::await_resume ();
 }

when the await_resume() function is made to return an int.

 final.suspend:
 frame_ptr->_Coro_resume_fn = 0B;
 {

 destroy.4:
 goto coro.delete.promise;
 resume.4:
 }

So we have a dangling label at the end of that scope (which then gives rise to
the crash).

* If I remove the 'contexpr' from the await_resume() function, then it all
works as expected.

* AFAICT, the content is correct in "expand_one_await_expression()".

* Altering the coroutines code to cast the result of the await_resume() to void
makes no difference.

[Bug c++/105104] [coroutines] ICE during GIMPLE pass: coro-early-expand-ifns

2022-03-31 Thread jehelset at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105104

--- Comment #5 from John Eivind Helset  ---
Created attachment 52729
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52729=edit
Patch with testcase.

Tried adding a testcase to the g++.dg/coroutines testsuite. Used dg-ice, but it
seems to complain about excess errors anyways:

FAIL: g++.dg/coroutines/pr105104.C (test for excess errors)
Excess errors:
during GIMPLE pass: coro-early-expand-ifns

[Bug c++/105104] [coroutines] ICE during GIMPLE pass: coro-early-expand-ifns

2022-03-31 Thread jehelset at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105104

--- Comment #4 from John Eivind Helset  ---
It seems a non-void return-type from await-resume of a final awaitable,
combined with at least -O1 causes a segfault: https://godbolt.org/z/rzq8dM7Pr

Not sure if it's the same as the one I initially encountered yet.

[Bug c++/105104] [coroutines] ICE during GIMPLE pass: coro-early-expand-ifns

2022-03-30 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105104

Richard Biener  changed:

   What|Removed |Added

   Last reconfirmed||2022-03-30
 Ever confirmed|0   |1
 Status|UNCONFIRMED |WAITING

--- Comment #3 from Richard Biener  ---
Please provide preprocessed source of a testcase.

[Bug c++/105104] [coroutines] ICE during GIMPLE pass: coro-early-expand-ifns

2022-03-30 Thread jehelset at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105104

--- Comment #2 from John Eivind Helset  ---
I'll try to create an MRE eventually...

[Bug c++/105104] [coroutines] ICE during GIMPLE pass: coro-early-expand-ifns

2022-03-29 Thread jehelset at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105104

--- Comment #1 from John Eivind Helset  ---
Indices of `bb` and `case_bb` in `convert_single_case_switch` are: 
(gdb) p bb->index
$18 = 154
(gdb) p case_bb->index
$19 = 157

If that helps.