public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure
@ 2023-04-30 21:37 dv at vollmann dot ch
  2023-04-30 21:39 ` [Bug c++/109682] " dv at vollmann dot ch
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dv at vollmann dot ch @ 2023-04-30 21:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109682
           Summary: coroutines: ICE in morph_fn_to_coro on wrong return
                    type for get_return_object_on_allocation_failure
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dv at vollmann dot ch
  Target Milestone: ---

Created attachment 54961
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54961&action=edit
Preprocessed source

Returning not the expected return type from
get_return_object_on_allocation_failure causes an internal compiler error:

g++ -std=c++23 wrong-promise-type-ice.cc
wrong-promise-type-ice.cc: In function 'CoHandle produce(QType&)':
wrong-promise-type-ice.cc:155:1: internal compiler error: in morph_fn_to_coro,
at cp/coroutines.cc:4766
  155 | }
      | ^
0x70d904 morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
        /build/src/gcc/gcc/cp/coroutines.cc:4766
0xa65905 finish_function(bool)
        /build/src/gcc/gcc/cp/decl.cc:18082
0xb64697 cp_parser_function_definition_after_declarator
        /build/src/gcc/gcc/cp/parser.cc:32049
0xb65b73 cp_parser_function_definition_from_specifiers_and_declarator
        /build/src/gcc/gcc/cp/parser.cc:31963
0xb65b73 cp_parser_init_declarator
        /build/src/gcc/gcc/cp/parser.cc:22822
0xb3a178 cp_parser_simple_declaration
        /build/src/gcc/gcc/cp/parser.cc:15435
0xb70353 cp_parser_declaration
        /build/src/gcc/gcc/cp/parser.cc:15121
0xb70e4a cp_parser_toplevel_declaration
        /build/src/gcc/gcc/cp/parser.cc:15142
0xb70e4a cp_parser_translation_unit
        /build/src/gcc/gcc/cp/parser.cc:5131
0xb70e4a c_parse_file()
        /build/src/gcc/gcc/cp/parser.cc:49627
0xcaf411 c_common_parse_file()
        /build/src/gcc/gcc/c-family/c-opts.cc:1248

Version:
GNU C++23 (GCC) version 14.0.0 20230430 (experimental) (x86_64-pc-linux-gnu)

Configured with: /build/src/gcc/configure --prefix=/opt/native/gcc
--disable-nls --enable-languages=c,c++

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/109682] coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure
  2023-04-30 21:37 [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure dv at vollmann dot ch
@ 2023-04-30 21:39 ` dv at vollmann dot ch
  2024-07-14 21:26 ` arsen at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dv at vollmann dot ch @ 2023-04-30 21:39 UTC (permalink / raw)
  To: gcc-bugs

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

dv at vollmann dot ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dv at vollmann dot ch

--- Comment #1 from dv at vollmann dot ch ---
Created attachment 54962
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54962&action=edit
The original file, <coroutine> is a header supplied by GCC

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/109682] coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure
  2023-04-30 21:37 [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure dv at vollmann dot ch
  2023-04-30 21:39 ` [Bug c++/109682] " dv at vollmann dot ch
@ 2024-07-14 21:26 ` arsen at gcc dot gnu.org
  2024-07-14 22:19 ` arsen at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: arsen at gcc dot gnu.org @ 2024-07-14 21:26 UTC (permalink / raw)
  To: gcc-bugs

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

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-07-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
                 CC|                            |arsen at gcc dot gnu.org

--- Comment #2 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
GCC presumes get_return_object_on_allocation_failure returns the same type as
the get_return_object function.  it trips there.

(conjecture) I think this is valid and should cause a conversion, but that it
was left as a TODO.

the standard does not state otherwise and both Clang and MSVC appear to attempt
a conversion.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/109682] coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure
  2023-04-30 21:37 [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure dv at vollmann dot ch
  2023-04-30 21:39 ` [Bug c++/109682] " dv at vollmann dot ch
  2024-07-14 21:26 ` arsen at gcc dot gnu.org
@ 2024-07-14 22:19 ` arsen at gcc dot gnu.org
  2024-08-24 18:55 ` cvs-commit at gcc dot gnu.org
  2024-08-27  7:52 ` iains at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: arsen at gcc dot gnu.org @ 2024-07-14 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
further reduced reproducer (this one should also be fully valid):

#include <coroutine>
#include <new>

struct test
{
  test () {}
  test (int) {}

  struct promise_type {
    test get_return_object () { return {}; }
    //     vvv
    static int get_return_object_on_allocation_failure () { return {}; }
    std::suspend_never initial_suspend () noexcept { return {}; }
    std::suspend_never final_suspend () noexcept { return {}; }
    void return_void () {}
    void unhandled_exception () {}
  };
};

test
f () { co_return; }

int
main ()
{
  f ();
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/109682] coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure
  2023-04-30 21:37 [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure dv at vollmann dot ch
                   ` (2 preceding siblings ...)
  2024-07-14 22:19 ` arsen at gcc dot gnu.org
@ 2024-08-24 18:55 ` cvs-commit at gcc dot gnu.org
  2024-08-27  7:52 ` iains at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-24 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:f4915e6c4cd42e7d6f397dc36fab507cc47dad05

commit r15-3152-gf4915e6c4cd42e7d6f397dc36fab507cc47dad05
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Aug 17 16:55:29 2024 +0100

    c++, coroutines: Allow convertible get_return_on_allocation_fail
[PR109682].

    We have been requiring the get_return_on_allocation_fail() call to have the
    same type as the ramp.  This is not intended by the standard, so relax that
    to allow anything convertible to the ramp return.

            PR c++/109682

    gcc/cp/ChangeLog:

            * coroutines.cc
            (cp_coroutine_transform::build_ramp_function): Allow for cases
where
            get_return_on_allocation_fail has a type convertible to the ramp
            return type.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr109682.C: New test.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/109682] coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure
  2023-04-30 21:37 [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure dv at vollmann dot ch
                   ` (3 preceding siblings ...)
  2024-08-24 18:55 ` cvs-commit at gcc dot gnu.org
@ 2024-08-27  7:52 ` iains at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: iains at gcc dot gnu.org @ 2024-08-27  7:52 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
           Assignee|unassigned at gcc dot gnu.org      |iains at gcc dot gnu.org

--- Comment #5 from Iain Sandoe <iains at gcc dot gnu.org> ---
fixed on trunk, waiting for possible back-port

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-27  7:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-30 21:37 [Bug c++/109682] New: coroutines: ICE in morph_fn_to_coro on wrong return type for get_return_object_on_allocation_failure dv at vollmann dot ch
2023-04-30 21:39 ` [Bug c++/109682] " dv at vollmann dot ch
2024-07-14 21:26 ` arsen at gcc dot gnu.org
2024-07-14 22:19 ` arsen at gcc dot gnu.org
2024-08-24 18:55 ` cvs-commit at gcc dot gnu.org
2024-08-27  7:52 ` iains at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).