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

            Bug ID: 85256
           Summary: [8 Regression] ICE with capturing pointer to VLA
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
  Target Milestone: ---

The following code snippet triggers an ICE on trunk:

=================================
void foo(int i)
{
  int (*x)[i];
  [=]{ [=]{ 0 ? x : x; }; };
}
=================================

bug.cc: In lambda function:
bug.cc:4:17: error: capture of variable-size type 'int (*)[i]' that is not an
N3639 array of runtime bound
   [=]{ [=]{ 0 ? x : x; }; };
                 ^
bug.cc:4:21: error: capture of variable-size type 'int (*)[i]' that is not an
N3639 array of runtime bound
   [=]{ [=]{ 0 ? x : x; }; };
                     ^
bug.cc: In lambda function:
bug.cc:4:24: internal compiler error: in insert_capture_proxy, at
cp/lambda.c:319
   [=]{ [=]{ 0 ? x : x; }; };
                        ^
0x615c84 insert_capture_proxy(tree_node*)
        ../../gcc/gcc/cp/lambda.c:319
0x8dbd9e insert_pending_capture_proxies()
        ../../gcc/gcc/cp/lambda.c:354
0x9260da cp_parser_lambda_expression
        ../../gcc/gcc/cp/parser.c:10212
0x9260da cp_parser_primary_expression
        ../../gcc/gcc/cp/parser.c:5263
0x938d7c cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:7022
0x939950 cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:8314
0x91974f cp_parser_cast_expression
        ../../gcc/gcc/cp/parser.c:9082
0x919f5a cp_parser_binary_expression
        ../../gcc/gcc/cp/parser.c:9183
0x91b794 cp_parser_assignment_expression
        ../../gcc/gcc/cp/parser.c:9478
0x91bea8 cp_parser_expression
        ../../gcc/gcc/cp/parser.c:9647
0x91db88 cp_parser_expression_statement
        ../../gcc/gcc/cp/parser.c:11123
0x923fcd cp_parser_statement
        ../../gcc/gcc/cp/parser.c:10927
0x925530 cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:11266
0x926007 cp_parser_lambda_body
        ../../gcc/gcc/cp/parser.c:10677
0x926007 cp_parser_lambda_expression
        ../../gcc/gcc/cp/parser.c:10178
0x926007 cp_parser_primary_expression
        ../../gcc/gcc/cp/parser.c:5263
0x938d7c cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:7022
0x939950 cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:8314
0x91974f cp_parser_cast_expression
        ../../gcc/gcc/cp/parser.c:9082
0x919f5a cp_parser_binary_expression
        ../../gcc/gcc/cp/parser.c:9183
Please submit a full bug report, [etc.]

The regression was introduced between 2017-10-07 and 2017-10-13.

I'm not sure whether the code is indeed invalid as the error messages suggest.
The code is accepted by GCC 4.5 - 4.8.
The code is accepted, if I use "int x[i]" instead of "int (*x)[i]".
And clang 3.6 - 5.0 accepts the code.

Reply via email to