From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6390 invoked by alias); 29 Jul 2015 07:01:30 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6343 invoked by uid 48); 29 Jul 2015 07:01:22 -0000 From: "ldionne.2 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67050] New: [C++14] ICE when calling a template member function from a lambda with implicit "this" capture Date: Wed, 29 Jul 2015 07:01:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ldionne.2 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-07/txt/msg02498.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67050 Bug ID: 67050 Summary: [C++14] ICE when calling a template member function from a lambda with implicit "this" capture Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldionne.2 at gmail dot com Target Milestone: --- Hi, The following code triggers an ICE (segmentation fault) on GCC trunk: --------------------------------------------------------------------- struct Foo { template void X() { } void test() { auto by_ref = [&](auto arg) { // anything that makes X<...> dependent will do X(); }; by_ref(1); auto by_val = [=](auto arg) { X(); }; by_val(1); } }; int main() { Foo foo; foo.test(); } --------------------------------------------------------------------- Formatted to fit the report, the error is: --------------------------------------------------------------------- prog.cc: In lambda function: prog.cc:8:29: internal compiler error: Segmentation fault X(); ^ 0xae69af crash_signal /home/heads/gcc/gcc-source/gcc/toplev.c:352 0x854887 size_binop_loc(unsigned int, tree_code, tree_node*, tree_node*) /home/heads/gcc/gcc-source/gcc/fold-const.c:1732 0x9308fd gimplify_compound_lval /home/heads/gcc/gcc-source/gcc/gimplify.c:2014 0x92bb93 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) /home/heads/gcc/gcc-source/gcc/gimplify.c:8021 0x9314bb gimplify_call_expr /home/heads/gcc/gcc-source/gcc/gimplify.c:2452 0x92d26d gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) /home/heads/gcc/gcc-source/gcc/gimplify.c:8040 0x92ea06 gimplify_stmt(tree_node**, gimple_statement_base**) /home/heads/gcc/gcc-source/gcc/gimplify.c:5525 0x92cf5d gimplify_cleanup_point_expr /home/heads/gcc/gcc-source/gcc/gimplify.c:5301 0x92cf5d gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) /home/heads/gcc/gcc-source/gcc/gimplify.c:8432 0x92ea06 gimplify_stmt(tree_node**, gimple_statement_base**) /home/heads/gcc/gcc-source/gcc/gimplify.c:5525 0x92f7af gimplify_bind_expr /home/heads/gcc/gcc-source/gcc/gimplify.c:1111 0x92d24c gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) /home/heads/gcc/gcc-source/gcc/gimplify.c:8266 0x92ea06 gimplify_stmt(tree_node**, gimple_statement_base**) /home/heads/gcc/gcc-source/gcc/gimplify.c:5525 0x93491e gimplify_body(tree_node*, bool) /home/heads/gcc/gcc-source/gcc/gimplify.c:9203 0x934c47 gimplify_function_tree(tree_node*) /home/heads/gcc/gcc-source/gcc/gimplify.c:9361 0x782da7 cgraph_node::analyze() /home/heads/gcc/gcc-source/gcc/cgraphunit.c:636 0x785447 analyze_functions /home/heads/gcc/gcc-source/gcc/cgraphunit.c:1028 0x785cf0 symbol_table::finalize_compilation_unit() /home/heads/gcc/gcc-source/gcc/cgraphunit.c:2477 ------------------------------------------------------------------------------ Live example: http://melpon.org/wandbox/permlink/eN6sRg5AacE50CrZ Note that Clang compiles this code just fine. Curiously enough, using any of the following lambdas will not trigger the ICE: (1) [this](auto arg) { X(); }; (2) [this](auto arg) { this->X(); }; (3) [=](auto arg) { this->X(); }; (4) [&](auto arg) { this->X(); }; I will also attach a test case checking for all of the above patterns. You might want to add this to GCC's unit tests. Related to 53741 and 54604 Maybe a duplicate of 61636 Regards, Louis Dionne