https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100673

            Bug ID: 100673
           Summary: [coroutines] Non-template, UDT await_suspend
                    return-type results in ICE.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jehelset at gmail dot com
  Target Milestone: ---

Created attachment 50844
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50844&action=edit
ICE on non-template UDT  await_suspend return-type.

A non-template udt return-type from await_suspend will ICE on trunk:

https://godbolt.org/z/Gn7djfrac

#0  build_co_await (loc=674010823, a=0x7ffff163f1c0, suspend_kind=<optimized
out>) at ../../gcc/cp/coroutines.cc:993
993           tree tt = CLASSTYPE_TI_TEMPLATE (susp_return_type);

Relevant code:
  else if (TREE_CODE (susp_return_type) == RECORD_TYPE
           && CLASS_TYPE_P (susp_return_type))
    {
      tree tt = CLASSTYPE_TI_TEMPLATE (susp_return_type);
      if (tt == coro_handle_templ)
        ok = true;
    }

Seems to be checking the validity of the await_suspend call, to produce a
helpful diagnostic. Perhaps the conditional also needs to verify that
CLASSTYPE_TEMPLATE_INFO (coro_handle_templ) is non-NULL, before using
CLASSTYPE_TI_TEMPLATE.

Seemed to be the case on 10.3, 11.1 and on 12.0. 10.2 failed to compile it
without crashing.

Reply via email to