public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105574] New: Internal compiler error when co_yield a r-value vector of non-POD type
@ 2022-05-12  0:19 wang_ruihan at hotmail dot com
  2022-05-12  0:24 ` [Bug c++/105574] " wang_ruihan at hotmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wang_ruihan at hotmail dot com @ 2022-05-12  0:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105574
           Summary: Internal compiler error when co_yield a r-value vector
                    of non-POD type
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wang_ruihan at hotmail dot com
  Target Milestone: ---

* System Info
Distributor ID: Ubuntu
Description:    Ubuntu 21.10
Release:        21.10
Codename:       impish

* GCC Version
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-7ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)

* Build Command
g++ -std=c++20 -fcoroutines -save-temps ../src/bug.cpp

* Description
The following code snippet (bug.cpp) will trigger an internal compiler error:

#include <coroutine>
#include <exception>
#include <iterator>
#include <iostream>
#include <optional>
#include <vector>

template<std::movable T>
class generator {
public:
    struct promise_type {
        generator<T> get_return_object() {
            return generator{Handle::from_promise(*this)};
        }
        static std::suspend_always initial_suspend() noexcept {
            return {}; 
        }
        static std::suspend_always final_suspend() noexcept { 
            return {}; 
        }
        std::suspend_always yield_value(T value) noexcept {
            current_value = std::move(value);
            return {};
        }
        // Disallow co_await in generator coroutines.
        void await_transform() = delete;
        [[noreturn]]
        static void unhandled_exception() {
            throw;
        }

        std::optional<T> current_value;
    };

    using Handle = std::coroutine_handle<promise_type>;

    explicit generator(const Handle coroutine) : 
        m_coroutine{coroutine}
    {}

    generator() = default;
    ~generator() { 
        if (m_coroutine) {
            m_coroutine.destroy(); 
        }
    }

    generator(const generator&) = delete;
    generator& operator=(const generator&) = delete;

    generator(generator&& other) noexcept : 
        m_coroutine{other.m_coroutine}
    { 
        other.m_coroutine = {}; 
    }
    generator& operator=(generator&& other) noexcept {
        if (this != &other) {
            if (m_coroutine) {
                m_coroutine.destroy();
            }
            m_coroutine = other.m_coroutine;
            other.m_coroutine = {};
        }
        return *this;
    }

private:
    Handle m_coroutine;
};

struct Foo {
    Foo() { }
};

generator<std::vector<Foo>> bug() {
    /* This one compiled fine */
    // auto v = std::vector<Foo>{ Foo() };
    // co_yield v;

    /* This one hit internal compiler error */
    co_yield std::vector<Foo>{ Foo() };
}

int main() {
    bug();
    return 0;
}


The error message is the following:

../src/bug.cpp: In function ‘generator<std::vector<Foo> > bug()’:
../src/bug.cpp:82:1: internal compiler error: in build_special_member_call, at
cp/call.c:10188
   82 | }
      | ^
0x7d7a1e build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        ../../src/gcc/cp/call.c:10188
0x9c3758 flatten_await_stmt
        ../../src/gcc/cp/coroutines.cc:3023
0x9c38b0 flatten_await_stmt
        ../../src/gcc/cp/coroutines.cc:3055
0x9c38b0 flatten_await_stmt
        ../../src/gcc/cp/coroutines.cc:3055
0x9c38b0 flatten_await_stmt
        ../../src/gcc/cp/coroutines.cc:3055
0x9c756e maybe_promote_temps
        ../../src/gcc/cp/coroutines.cc:3241
0x9c756e await_statement_walker
        ../../src/gcc/cp/coroutines.cc:3879
0xf49a8a 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*> >*))
        ../../src/gcc/tree.c:12108
0x9c6d93 await_statement_walker
        ../../src/gcc/cp/coroutines.cc:3557
0xf49a8a 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*> >*))
        ../../src/gcc/tree.c:12108
0xf49c21 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*> >*))
        ../../src/gcc/tree.c:12456
0x9c6d93 await_statement_walker
        ../../src/gcc/cp/coroutines.cc:3557
0xf49a8a 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*> >*))
        ../../src/gcc/tree.c:12108
0x9c6d49 await_statement_walker
        ../../src/gcc/cp/coroutines.cc:3545
0xf49a8a 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*> >*))
        ../../src/gcc/tree.c:12108
0x9e60b5 morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
        ../../src/gcc/cp/coroutines.cc:4547
0x6b9a6d finish_function(bool)
        ../../src/gcc/cp/decl.c:17326
0xff88d6 cp_parser_function_definition_after_declarator
        ../../src/gcc/cp/parser.c:30093
0xfa785e cp_parser_function_definition_from_specifiers_and_declarator
        ../../src/gcc/cp/parser.c:30006
0xfa785e cp_parser_init_declarator
        ../../src/gcc/cp/parser.c:21667
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.

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

* [Bug c++/105574] Internal compiler error when co_yield a r-value vector of non-POD type
  2022-05-12  0:19 [Bug c++/105574] New: Internal compiler error when co_yield a r-value vector of non-POD type wang_ruihan at hotmail dot com
@ 2022-05-12  0:24 ` wang_ruihan at hotmail dot com
  2022-05-12  8:45 ` marxin at gcc dot gnu.org
  2023-08-05 16:42 ` [Bug c++/105574] coroutines: ICE " pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: wang_ruihan at hotmail dot com @ 2022-05-12  0:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Ruihan Wang <wang_ruihan at hotmail dot com> ---
Created attachment 52958
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52958&action=edit
Preprocessed source file

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

* [Bug c++/105574] Internal compiler error when co_yield a r-value vector of non-POD type
  2022-05-12  0:19 [Bug c++/105574] New: Internal compiler error when co_yield a r-value vector of non-POD type wang_ruihan at hotmail dot com
  2022-05-12  0:24 ` [Bug c++/105574] " wang_ruihan at hotmail dot com
@ 2022-05-12  8:45 ` marxin at gcc dot gnu.org
  2023-08-05 16:42 ` [Bug c++/105574] coroutines: ICE " pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-12  8:45 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |12.1.0, 13.0
   Last reconfirmed|                            |2022-05-12
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed with r12-618-g14ed21f8749ae359.

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

* [Bug c++/105574] coroutines: ICE when co_yield a r-value vector of non-POD type
  2022-05-12  0:19 [Bug c++/105574] New: Internal compiler error when co_yield a r-value vector of non-POD type wang_ruihan at hotmail dot com
  2022-05-12  0:24 ` [Bug c++/105574] " wang_ruihan at hotmail dot com
  2022-05-12  8:45 ` marxin at gcc dot gnu.org
@ 2023-08-05 16:42 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redboltz at gmail dot com

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110913 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-08-05 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12  0:19 [Bug c++/105574] New: Internal compiler error when co_yield a r-value vector of non-POD type wang_ruihan at hotmail dot com
2022-05-12  0:24 ` [Bug c++/105574] " wang_ruihan at hotmail dot com
2022-05-12  8:45 ` marxin at gcc dot gnu.org
2023-08-05 16:42 ` [Bug c++/105574] coroutines: ICE " pinskia 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).