public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99827] New: [coroutines] co_await on function receiving initializer list of shared pointers causes ICE
@ 2021-03-30 12:35 inf17092 at lehre dot dhbw-stuttgart.de
  2021-03-30 12:54 ` [Bug c++/99827] [10/11 Regression] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: inf17092 at lehre dot dhbw-stuttgart.de @ 2021-03-30 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99827
           Summary: [coroutines] co_await on function receiving
                    initializer list of shared pointers causes ICE
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: inf17092 at lehre dot dhbw-stuttgart.de
  Target Milestone: ---

When using coroutines and awaiting the return value of a function receiving an
initializer list of shared pointers, the tree check fails with the following
error:

  internal compiler error: tree check: expected record_type or union_type or
qual_union_type, have array_type in build_special_member_call, at
cp/call.c:10143

When using the promise type `promise::promise_type`, the following function
produces the error. In this case, `func1` receives the initializer list of
shared pointers and returns an awaitable.

  promise task() {
    co_await func1({ std::make_shared<int>(1) });
  }

You can find a short sample file demonstrating the bug and the full error
output here: https://godbolt.org/z/489EcWdb3. The bug also occurs with version
10.2.0-5 on my local Ubuntu system but not with version 10.2.0 on godbolt.org.

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

* [Bug c++/99827] [10/11 Regression] [coroutines] co_await on function receiving initializer list of shared pointers causes ICE
  2021-03-30 12:35 [Bug c++/99827] New: [coroutines] co_await on function receiving initializer list of shared pointers causes ICE inf17092 at lehre dot dhbw-stuttgart.de
@ 2021-03-30 12:54 ` redi at gcc dot gnu.org
  2021-03-30 13:01 ` rguenth at gcc dot gnu.org
  2021-03-30 13:13 ` iains at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-30 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
      Known to work|                            |10.2.0
      Known to fail|                            |10.2.1, 11.0
                 CC|                            |iains at gcc dot gnu.org
   Last reconfirmed|                            |2021-03-30
            Summary|[coroutines] co_await on    |[10/11 Regression]
                   |function receiving          |[coroutines] co_await on
                   |initializer list of shared  |function receiving
                   |pointers causes ICE         |initializer list of shared
                   |                            |pointers causes ICE

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please provide the code here, not just a URL (as requested by
https://gcc.gnu.org/bugs which bugzilla asks you to read before creating a
bug).


#include <coroutine>
#include <memory>

// promise
struct promise {
  struct promise_type {
    promise get_return_object() { return {}; }
    std::suspend_never initial_suspend() { return {}; }
    std::suspend_never final_suspend() noexcept { return {}; }
    void unhandled_exception() {};
  };
};

// generate awaitable (1)
std::suspend_never func1(std::initializer_list<std::shared_ptr<int>>) { return
{}; }

// generate awaitable (2)
std::suspend_never func2(std::initializer_list<int>) { return {}; }

promise task() {
  {
    // produces a compiler error
    co_await func1({ std::make_shared<int>(1) });
  }

  {
    // does not produce a compiler error
    func1({ std::make_shared<int>(1) });
  }

  {
    // does not produce a compiler error
    auto is = { std::make_shared<int>(1) };
    co_await func1(is);
  }

  {
    // does not produce a compiler error
    co_await func2({ 1 });
  }
}

int main() { task(); }


co.C: In function 'promise task()':
co.C:41:1: internal compiler error: tree check: expected record_type or
union_type or qual_union_type, have array_type in build_special_member_call, at
cp/call.c:10106
   41 | }
      | ^
0x80cc4f tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        /home/jwakely/src/gcc/gcc/gcc/tree.c:9816
0x6178b5 tree_check3(tree_node*, char const*, int, char const*, tree_code,
tree_code, tree_code)
        /home/jwakely/src/gcc/gcc/gcc/tree.h:3393
0x6178b5 build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        /home/jwakely/src/gcc/gcc/gcc/cp/call.c:10106
0x9300a4 flatten_await_stmt
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:2973
0x92fcb6 flatten_await_stmt
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:2991
0x92fcb6 flatten_await_stmt
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:2991
0x9314fb maybe_promote_temps
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3176
0x9314fb await_statement_walker
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3681
0x137e72a 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12101
0x931000 await_statement_walker
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3441
0x137e72a 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12101
0x9316de await_statement_walker
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3429
0x137e72a 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12101
0x931000 await_statement_walker
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3441
0x137e72a 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12101
0x137e8ce 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12449
0x931000 await_statement_walker
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3441
0x137e72a 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12101
0x9316de await_statement_walker
        /home/jwakely/src/gcc/gcc/gcc/cp/coroutines.cc:3429
0x137e72a 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*> >*))
        /home/jwakely/src/gcc/gcc/gcc/tree.c:12101
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

It works with 10.2.0 but not 10.2.1

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

* [Bug c++/99827] [10/11 Regression] [coroutines] co_await on function receiving initializer list of shared pointers causes ICE
  2021-03-30 12:35 [Bug c++/99827] New: [coroutines] co_await on function receiving initializer list of shared pointers causes ICE inf17092 at lehre dot dhbw-stuttgart.de
  2021-03-30 12:54 ` [Bug c++/99827] [10/11 Regression] " redi at gcc dot gnu.org
@ 2021-03-30 13:01 ` rguenth at gcc dot gnu.org
  2021-03-30 13:13 ` iains at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-30 13:01 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.3

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

* [Bug c++/99827] [10/11 Regression] [coroutines] co_await on function receiving initializer list of shared pointers causes ICE
  2021-03-30 12:35 [Bug c++/99827] New: [coroutines] co_await on function receiving initializer list of shared pointers causes ICE inf17092 at lehre dot dhbw-stuttgart.de
  2021-03-30 12:54 ` [Bug c++/99827] [10/11 Regression] " redi at gcc dot gnu.org
  2021-03-30 13:01 ` rguenth at gcc dot gnu.org
@ 2021-03-30 13:13 ` iains at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2021-03-30 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
see 98056

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

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

end of thread, other threads:[~2021-03-30 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30 12:35 [Bug c++/99827] New: [coroutines] co_await on function receiving initializer list of shared pointers causes ICE inf17092 at lehre dot dhbw-stuttgart.de
2021-03-30 12:54 ` [Bug c++/99827] [10/11 Regression] " redi at gcc dot gnu.org
2021-03-30 13:01 ` rguenth at gcc dot gnu.org
2021-03-30 13:13 ` 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).