public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eng.amehra at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95388] New: C++20 & 17 Lambda capture of *this by Value causes ICE "in tsubst_decl at cp/pt.c" Date: Thu, 28 May 2020 15:19:16 +0000 [thread overview] Message-ID: <bug-95388-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95388 Bug ID: 95388 Summary: C++20 & 17 Lambda capture of *this by Value causes ICE "in tsubst_decl at cp/pt.c" Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eng.amehra at gmail dot com Target Milestone: --- 1. While using lambda capture by value, cause ICE with gcc 11.0.0. I tried with both -std=c++17 & then with -std=c++20. Both give same error. Short Error: internal compiler error: in tsubst_decl, at cp/pt.c:14637 What works: 1. On this online gcc comiler, it works for gcc10.1, but fails for trunk. Code Code fails to compile on this link when compiler is set to gcc trunk - https://godbolt.org/z/PNxfQc Same code compiles on this link when compiler is set to gcc10.1 - https://godbolt.org/z/izPfY_ 2. It works fine with GCC 7.5.0 with compiler flag -std=c++17 on my machine. (See machine details below) My local machine details: Linux DESKTOP-SHA8RMO 4.4.0-18362-Microsoft #836-Microsoft x86_64 x86_64 x86_64 GNU/Linux OS: "Ubuntu 18.04.4 LTS (Bionic Beaver)". Code sample which causes error: #include <iostream> #include <vector> #include <algorithm> class FeatureLambdaCaptureThis { private: int addend; public: FeatureLambdaCaptureThis(int value) : addend{value} { } void DemoLambdaCapture_ThisByValue() { std::vector<int> values{1, 3, 5, 7, 9, 11, 13, 15}; std::for_each(values.begin(), values.end(), [=, *this](auto &value) mutable { value += addend; addend++; }); std::cout << "\n" ; for (auto &value : values) { std::cout << " " << value; } std::cout << std::endl; } }; int main(int argc, char *argv[]) { std::cout << "__cplusplus:" << __cplusplus << std::endl; FeatureLambdaCaptureThis obj{2}; obj.DemoLambdaCapture_ThisByValue(); } Detailed error log from my local machine: 51 | std::for_each(values.begin(), values.end(), [=, *this](auto value) { [build] | ^ [build] 0x69059f tsubst_decl [build] ../../gcc/cp/pt.c:14637 [build] 0xa2c8eb tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:17934 [build] 0xa2b96a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:17832 [build] 0xa29d14 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:18151 [build] 0xa27c91 instantiate_decl(tree_node*, bool, bool) [build] ../../gcc/cp/pt.c:25622 [build] 0x95ce6a maybe_instantiate_decl [build] ../../gcc/cp/decl2.c:5377 [build] 0x95f520 maybe_instantiate_decl [build] ../../gcc/tree.h:3411 [build] 0x95f520 mark_used(tree_node*, int) [build] ../../gcc/cp/decl2.c:5573 [build] 0x8b3385 build_over_call [build] ../../gcc/cp/call.c:9082 [build] 0x8b8141 build_op_call_1 [build] ../../gcc/cp/call.c:4889 [build] 0x8b8141 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) [build] ../../gcc/cp/call.c:4918 [build] 0xa6f3ee finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) [build] ../../gcc/cp/semantics.c:2692 [build] 0xa39bdd tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) [build] ../../gcc/cp/pt.c:20017 [build] 0xa28439 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:18750 [build] 0xa2a963 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:17862 [build] 0xa2a3c3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:18061 [build] 0xa2b96a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:17832 [build] 0xa29d14 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../gcc/cp/pt.c:18151 [build] 0xa27c91 instantiate_decl(tree_node*, bool, bool) [build] ../../gcc/cp/pt.c:25622 [build] 0x8dab1e instantiate_cx_fn_r [build] ../../gcc/cp/constexpr.c:6549 [build] Please submit a full bug report, [build] with preprocessed source if appropriate. [build] Please include the complete backtrace with any bug report. [build] See <https://gcc.gnu.org/bugs/> for instructions.
next reply other threads:[~2020-05-28 15:19 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-28 15:19 eng.amehra at gmail dot com [this message] 2020-06-26 12:06 ` [Bug c++/95388] [11 Regression] " rguenth at gcc dot gnu.org 2020-10-16 11:49 ` rguenth 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-95388-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).