public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "leni536 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98326] New: ICE: in create_tmp_var, at gimple-expr.c:482, converting stateless generic-lambda to function pointer Date: Wed, 16 Dec 2020 18:17:41 +0000 [thread overview] Message-ID: <bug-98326-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98326 Bug ID: 98326 Summary: ICE: in create_tmp_var, at gimple-expr.c:482, converting stateless generic-lambda to function pointer Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: leni536 at gmail dot com Target Milestone: --- version: g++ (Compiler-Explorer-Build) 10.2.0 arguments: -O2 -std=c++17 -pedantic-errors ``` struct A { A() = default; A(const A&) {} }; void (*fptr)(A) = [](auto){}; ``` <source>: In static member function 'static constexpr decltype (((const<lambda(auto:1)>*)0)->operator()<auto:1>(static_cast<auto:1&&>(<anonymous>)))<lambda(auto:1)>::_FUN(auto:1) [with auto:1 = A]': <source>:6:28: internal compiler error: in create_tmp_var, at gimple-expr.c:482 6 | void (*fptr)(A) = [](auto){}; | ^ The ICE seems to happen when the by-value parameter's type is not trivially copyable. It can also be reproduced with a non-trivial destructor. If the copy-constructor is deleted then it fails to compile with a non-ice error. Related: PR 86943 In my understanding gcc tries to copy/move the by-value parameter in the free function to pass it to `closure{}(args)`. I don't think that copying/moving the by-value argument is correct. The effect of calling the resulting function pointer should be equivalent to calling the operator() on the closure object, it's not expressed in terms of forwarding the parameters: https://timsong-cpp.github.io/cppwp/n4659/expr.prim.lambda.closure#8 It's more precisely spelled out in C++20, as there it can be expressed it in terms of a default constructed object of the closure type: http://eel.is/c++draft/expr.prim.lambda.closure#10.sentence-1
next reply other threads:[~2020-12-16 18:17 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-16 18:17 leni536 at gmail dot com [this message] 2020-12-17 11:05 ` [Bug c++/98326] [10/11 Regression] ICE: in create_tmp_var, at gimple-expr.c:482, converting stateless generic-lambda to function pointer since r10-599-gc652ff8312433483 marxin at gcc dot gnu.org 2021-01-04 15:30 ` rguenth at gcc dot gnu.org 2021-02-03 13:22 ` jakub at gcc dot gnu.org 2021-02-08 21:15 ` jason at gcc dot gnu.org 2021-02-09 1:52 ` cvs-commit at gcc dot gnu.org 2021-02-12 2:30 ` cvs-commit at gcc dot gnu.org 2021-02-12 2:50 ` jason at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-98326-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).