public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114850] New: co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE
@ 2024-04-25  9:40 jeremypewterschmidt at gmail dot com
  2024-04-25  9:42 ` [Bug c++/114850] " jeremypewterschmidt at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jeremypewterschmidt at gmail dot com @ 2024-04-25  9:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114850
           Summary: co_await a async function which result type is
                    std::unique_ptr<...> or shared_ptr in a initializer
                    list causes ICE
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeremypewterschmidt at gmail dot com
  Target Milestone: ---

I've noticed that there're some reports looks like the same, but I still
decided to report this to give you more information to help to resolve the
problem. But please make sure you read the snippet first.


Related reports: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99827


OS: Arch Linux x86_64 with kernel 6.8.7-zen1-1-zen 

Although the OS is arch, but I have also tried this code in compiler explorer
with the same version, same options.

message dumped by g++ --version:
g++ (GCC) 13.2.1 20230801
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


command: g++ main.cpp --std=c++20 -freport-bug


Snippet caused the problem: 

```c++
#include <coroutine>
#include <vector>
#include <memory>
//#include <optional>

template<typename T>
struct Task {
    struct Awaitable {
        std::coroutine_handle<> coroutine;
        T result;

        bool await_ready() { return false; }
        void await_suspend(std::coroutine_handle<> h) { coroutine = h; }
        T await_resume() { return ::std::move(result); }
    };

    struct promise_type {
        T value;

        auto get_return_object() { return Task{
std::coroutine_handle<promise_type>::from_promise(*this) }; }
        auto initial_suspend() { return std::suspend_never{}; }
        auto final_suspend() noexcept { return std::suspend_always{}; }
        void return_value(T val) { value = ::std::move(val); }
        void unhandled_exception() {}
    };

    std::coroutine_handle<promise_type> coroutine;

    Task(std::coroutine_handle<promise_type> coroutine) : coroutine(coroutine)
{}

    ~Task() noexcept {
        if (coroutine)
            coroutine.destroy();
    }

    T getResult() {
        return coroutine.promise().value;
    }

    Awaitable operator co_await() {
        return { coroutine, ::std::move(coroutine.promise().value) };
    }
};

Task<::std::unique_ptr<int>> uniqueGuy() {
    co_return nullptr;
}

Task<::std::shared_ptr<int>> sharedGuy() {
    co_return nullptr;
}

//Task<::std::optional<int>> optionalGuy() {
//    co_return ::std::optional<int>();
//}

Task<int> intGuy()
{
    co_return 0;
}

Task<int> asyncFunction() {
//    // OK
//    ::std::vector iVec{ 
//        co_await intGuy(), 
//        co_await intGuy(), 
//    };
//
//    // OK
//    ::std::vector optVec{ 
//        co_await optionalGuy(), 
//        co_await optionalGuy(), 
//    };

//    // ICE
//    ::std::vector uniqueVec{ 
//        co_await uniqueGuy(), 
//        co_await uniqueGuy(), 
//    };
//
    // ICE
    ::std::vector<::std::unique_ptr<int>> uniqueVec2{ 
        co_await uniqueGuy(), 
        co_await uniqueGuy(), 
    };

//    // OK
//    ::std::vector<::std::unique_ptr<int>> uniqueVec3; 
//    uniqueVec3.push_back(co_await uniqueGuy());
//    uniqueVec3.push_back(co_await uniqueGuy());

//    // ICE
//    ::std::vector sharedVec{ 
//        co_await sharedGuy(), 
//        co_await sharedGuy(), 
//    };

    co_return 0;
}

int main() {
    return 0;
}

```

The ICE message:
src/main.cpp: In function ‘Task<int> asyncFunction()’:
src/main.cpp:99:1: internal compiler error: in build_special_member_call, at
cp/call.cc:11093
   99 | }
      | ^
0x1ad33c8 internal_error(char const*, ...)
        ???:0
0x6b7b63 fancy_abort(char const*, int, char const*)
        ???:0
0x10dc463 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x10dc463 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x10dc463 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x10dc463 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x10dc583 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x10dc463 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x10dc463 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x74de91 finish_function(bool)
        ???:0
0x9443d0 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
Preprocessed source stored into /tmp/ccKd9Ia9.out file, please attach this to
your bugreport.

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

* [Bug c++/114850] co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE
  2024-04-25  9:40 [Bug c++/114850] New: co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE jeremypewterschmidt at gmail dot com
@ 2024-04-25  9:42 ` jeremypewterschmidt at gmail dot com
  2024-04-25  9:44 ` jeremypewterschmidt at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jeremypewterschmidt at gmail dot com @ 2024-04-25  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jeremy Pewterschmidt <jeremypewterschmidt at gmail dot com> ---
Created attachment 58038
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58038&action=edit
compressed file generated by g++ with -freport-bug

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

* [Bug c++/114850] co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE
  2024-04-25  9:40 [Bug c++/114850] New: co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE jeremypewterschmidt at gmail dot com
  2024-04-25  9:42 ` [Bug c++/114850] " jeremypewterschmidt at gmail dot com
@ 2024-04-25  9:44 ` jeremypewterschmidt at gmail dot com
  2024-05-16 15:15 ` jeremypewterschmidt at gmail dot com
  2024-05-16 15:44 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jeremypewterschmidt at gmail dot com @ 2024-04-25  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jeremy Pewterschmidt <jeremypewterschmidt at gmail dot com> ---
Created attachment 58039
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58039&action=edit
compressed file generated by g++ with -save-temps

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

* [Bug c++/114850] co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE
  2024-04-25  9:40 [Bug c++/114850] New: co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE jeremypewterschmidt at gmail dot com
  2024-04-25  9:42 ` [Bug c++/114850] " jeremypewterschmidt at gmail dot com
  2024-04-25  9:44 ` jeremypewterschmidt at gmail dot com
@ 2024-05-16 15:15 ` jeremypewterschmidt at gmail dot com
  2024-05-16 15:44 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jeremypewterschmidt at gmail dot com @ 2024-05-16 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jeremy Pewterschmidt <jeremypewterschmidt at gmail dot com> ---
This issue is no longer reproducible in GCC 14.
Should I mark this as `RESOLVED` ?

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

* [Bug c++/114850] co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE
  2024-04-25  9:40 [Bug c++/114850] New: co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE jeremypewterschmidt at gmail dot com
                   ` (2 preceding siblings ...)
  2024-05-16 15:15 ` jeremypewterschmidt at gmail dot com
@ 2024-05-16 15:44 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-16 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jeremy Pewterschmidt from comment #3)
> This issue is no longer reproducible in GCC 14.
> Should I mark this as `RESOLVED` ?
Yes, the ICE disappeared after r14-8437-g44868e7298de50, so I reckon this is a
dup of 109227.

*** This bug has been marked as a duplicate of bug 109227 ***

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

end of thread, other threads:[~2024-05-16 15:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25  9:40 [Bug c++/114850] New: co_await a async function which result type is std::unique_ptr<...> or shared_ptr in a initializer list causes ICE jeremypewterschmidt at gmail dot com
2024-04-25  9:42 ` [Bug c++/114850] " jeremypewterschmidt at gmail dot com
2024-04-25  9:44 ` jeremypewterschmidt at gmail dot com
2024-05-16 15:15 ` jeremypewterschmidt at gmail dot com
2024-05-16 15:44 ` ppalka 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).