Bug 84618 - [8 Regression] ICE in build_capture_proxy, at cp/lambda.c:460
Summary: [8 Regression] ICE in build_capture_proxy, at cp/lambda.c:460
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P4 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, error-recovery, ice-on-invalid-code
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2018-02-28 16:26 UTC by Vegard Nossum
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vegard Nossum 2018-02-28 16:26:06 UTC
Input:

template<int>
void a() {
  struct {
    void b() const;
    void b() { [b] }
  };
};

Output:

$ xgcc -x c++ -S input.cc
input.cc: In lambda function:
input.cc:5:18: internal compiler error: in build_capture_proxy, at cp/lambda.c:460
     void b() { [b] }
                  ^
0xd425db build_capture_proxy
        /home/vegard/git/gcc/gcc/cp/lambda.c:460
0xd55770 start_lambda_function(tree_node*, tree_node*)
        /home/vegard/git/gcc/gcc/cp/lambda.c:1377
0xfd1f1d cp_parser_lambda_body
        /home/vegard/git/gcc/gcc/cp/parser.c:10668
0xfd1f1d cp_parser_lambda_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:10182
0xf37404 cp_parser_primary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:5257
0xf78edb cp_parser_postfix_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:7026
0xf2cc47 cp_parser_unary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:8318
0xec1cba cp_parser_cast_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9086
0xec42e6 cp_parser_binary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9187
0xec80ba cp_parser_assignment_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9482
0xecc026 cp_parser_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9651
0xee05a6 cp_parser_expression_statement
        /home/vegard/git/gcc/gcc/cp/parser.c:11127
0xefbf30 cp_parser_statement
        /home/vegard/git/gcc/gcc/cp/parser.c:10931
0xf0043b cp_parser_statement_seq_opt
        /home/vegard/git/gcc/gcc/cp/parser.c:11270
0xf00eda cp_parser_compound_statement
        /home/vegard/git/gcc/gcc/cp/parser.c:11224
0xf953eb cp_parser_function_body
        /home/vegard/git/gcc/gcc/cp/parser.c:21767
0xf953eb cp_parser_ctor_initializer_opt_and_function_body
        /home/vegard/git/gcc/gcc/cp/parser.c:21802
0xf9e5f5 cp_parser_function_definition_after_declarator
        /home/vegard/git/gcc/gcc/cp/parser.c:26703
0xfa08bc cp_parser_late_parsing_for_member
        /home/vegard/git/gcc/gcc/cp/parser.c:27584
0xf19ac5 cp_parser_class_specifier_1
        /home/vegard/git/gcc/gcc/cp/parser.c:22731

xgcc --version
xgcc (GCC) 8.0.1 20180228 (experimental)

This looks potentially similar to bug #84160, but I'm running a more recent version where that bug should be already fixed.
Comment 1 David Malcolm 2018-02-28 18:43:36 UTC
Confirmed.  Started with r253265.
Comment 2 David Malcolm 2018-02-28 19:01:33 UTC
Failing here in build_capture_proxy (member=<field_decl 0x7ffff19d57b8 __b>, init=<component_ref 0x7ffff18abb70>) at ../../src/gcc/cp/lambda.c:458:

458	      gcc_assert (VAR_P (init) || TREE_CODE (init) == PARM_DECL);

where init is a component_ref.
Comment 3 Paolo Carlini 2018-03-05 00:24:49 UTC
Looking into it.
Comment 4 paolo@gcc.gnu.org 2018-03-05 15:40:46 UTC
Author: paolo
Date: Mon Mar  5 15:40:15 2018
New Revision: 258250

URL: https://gcc.gnu.org/viewcvs?rev=258250&root=gcc&view=rev
Log:
/cp
2018-03-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84618
	* parser.c (cp_parser_lambda_introducer): Reject any capture not
	involving a VAR_DECL or a PARM_DECL.

/testsuite
2018-03-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84618
	* g++.dg/cpp0x/lambda/lambda-ice29.C: New.
	* g++.dg/cpp0x/lambda/lambda-ice17.C: Adjust.
	* g++.dg/cpp0x/lambda/lambda-ice23.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C
Comment 5 Paolo Carlini 2018-03-05 15:41:38 UTC
Fixed.