public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570
@ 2020-06-29 16:24 haoxintu at gmail dot com
  2020-07-03  3:14 ` [Bug c++/95972] " haoxintu at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-29 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95972
           Summary: ICE in check_member_template, at cp/decl2.c:570
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
a() { [] ( struct { b ( auto

$g++ -w bug.cc
bug.cc:1:1: error: ISO C++ forbids declaration of ‘a’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
    1 | a() { [] ( struct { b ( auto
      | ^
bug.cc: In function ‘int a()’:
bug.cc:1:19: error: types may not be defined in parameter types
    1 | a() { [] ( struct { b ( auto
      |                   ^
bug.cc:2: error: expected ‘,’ or ‘...’ at end of input
bug.cc:1:29: error: expected ‘)’ at end of input
    1 | a() { [] ( struct { b ( auto
      |                       ~     ^
      |                             )
bug.cc:1:21: error: ISO C++ forbids declaration of ‘b’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
    1 | a() { [] ( struct { b ( auto
      |                     ^
bug.cc:2: internal compiler error: in check_member_template, at cp/decl2.c:570
0x61d665 check_member_template(tree_node*)
        ../../gcc/cp/decl2.c:570
0x9d3490 finish_member_template_decl(tree_node*)
        ../../gcc/cp/pt.c:308
0x989fba finish_fully_implicit_template
        ../../gcc/cp/parser.c:44279
0x9cb99a cp_parser_member_declaration
        ../../gcc/cp/parser.c:25414
0x99f921 cp_parser_member_specification_opt
        ../../gcc/cp/parser.c:24850
0x99f921 cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:23947
0x9a1aa3 cp_parser_class_specifier
        ../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14410
0x9bf3ef cp_parser_parameter_declaration
        ../../gcc/cp/parser.c:22818
0x9bfdd2 cp_parser_parameter_declaration_list
        ../../gcc/cp/parser.c:22641
0x9c01bc cp_parser_parameter_declaration_clause
        ../../gcc/cp/parser.c:22568
0x9c0bae cp_parser_lambda_declarator_opt
        ../../gcc/cp/parser.c:11102
0x9a8836 cp_parser_lambda_expression
        ../../gcc/cp/parser.c:10633
0x9a8836 cp_parser_primary_expression
        ../../gcc/cp/parser.c:5443
0x9b2960 cp_parser_postfix_expression
        ../../gcc/cp/parser.c:7296
0x99564a cp_parser_binary_expression
        ../../gcc/cp/parser.c:9609
0x9971ae cp_parser_assignment_expression
        ../../gcc/cp/parser.c:9914
0x9974d2 cp_parser_expression
        ../../gcc/cp/parser.c:10082
0x99a368 cp_parser_expression_statement
        ../../gcc/cp/parser.c:11742
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570
  2020-06-29 16:24 [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570 haoxintu at gmail dot com
@ 2020-07-03  3:14 ` haoxintu at gmail dot com
  2020-07-08 12:40 ` haoxintu at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-03  3:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Haoxin Tu <haoxintu at gmail dot com> ---
Hi, there.

I guess I shouldn't use C-Reduce to reduce my ICE on invalid code cases. After
using C-Reduce, the cases are more like a "garbage" code.

Here is a more readable code to reproduce the ICE.

$cat p.cc
int a() { 
    auto var = [] ( struct s{ int b( auto);} ){};
}

$g++ -w p.cc
p.cc: In function ‘int a()’:
p.cc:2:29: error: types may not be defined in parameter types
    2 |     auto var = [] ( struct s{ int b( auto);} ){};
      |                             ^
p.cc:2:42: internal compiler error: in check_member_template, at cp/decl2.c:570
    2 |     auto var = [] ( struct s{ int b( auto);} ){};
      |                                          ^
0x6890c4 check_member_template(tree_node*)
        ../../gcc/cp/decl2.c:570
0xa41c20 finish_member_template_decl(tree_node*)
        ../../gcc/cp/pt.c:308
0x9f86ba finish_fully_implicit_template
        ../../gcc/cp/parser.c:44279
0xa3a12a cp_parser_member_declaration
        ../../gcc/cp/parser.c:25414
0xa0e061 cp_parser_member_specification_opt
        ../../gcc/cp/parser.c:24850
0xa0e061 cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:23947
0xa10213 cp_parser_class_specifier
        ../../gcc/cp/parser.c:24254
0xa10213 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17762
0xa11172 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14410
0xa2db8f cp_parser_parameter_declaration
        ../../gcc/cp/parser.c:22818
0xa2e582 cp_parser_parameter_declaration_list
        ../../gcc/cp/parser.c:22641
0xa2e95c cp_parser_parameter_declaration_clause
        ../../gcc/cp/parser.c:22568
0xa2f34e cp_parser_lambda_declarator_opt
        ../../gcc/cp/parser.c:11102
0xa16fb8 cp_parser_lambda_expression
        ../../gcc/cp/parser.c:10633
0xa16fb8 cp_parser_primary_expression
        ../../gcc/cp/parser.c:5443
0xa21110 cp_parser_postfix_expression
        ../../gcc/cp/parser.c:7296
0xa03d6a cp_parser_binary_expression
        ../../gcc/cp/parser.c:9609
0xa058ce cp_parser_assignment_expression
        ../../gcc/cp/parser.c:9914
0xa0468d cp_parser_constant_expression
        ../../gcc/cp/parser.c:10208
0xa04df1 cp_parser_initializer_clause
        ../../gcc/cp/parser.c:23272
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

While in Clang
$clang++ -w p.cc
p.cc:2:28: error: 's' cannot be defined in a parameter type
    auto var = [] ( struct s{ int b( auto);} ){};
                           ^
1 error generated.

The ICE just cased by the struct used as a lambda expression parameter. And ICE
point out the parser can not deal with the "auto" keywords and then crashed on
it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570
  2020-06-29 16:24 [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570 haoxintu at gmail dot com
  2020-07-03  3:14 ` [Bug c++/95972] " haoxintu at gmail dot com
@ 2020-07-08 12:40 ` haoxintu at gmail dot com
  2020-07-08 14:05 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-08 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Haoxin Tu <haoxintu at gmail dot com> ---
Update a new case.

Input:
int a() { [] ( auto class {int b()}}

Output:
<source>: In function 'int a()':
<source>:1:27: error: types may not be defined in parameter types
    1 | int a() { [] ( auto class {int b()}}
      |                           ^
<source>:1:34: internal compiler error: in check_member_template, at
cp/decl2.c:568
    1 | int a() { [] ( auto class {int b()}}
      |                                  ^

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570
  2020-06-29 16:24 [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570 haoxintu at gmail dot com
  2020-07-03  3:14 ` [Bug c++/95972] " haoxintu at gmail dot com
  2020-07-08 12:40 ` haoxintu at gmail dot com
@ 2020-07-08 14:05 ` mpolacek at gcc dot gnu.org
  2020-07-08 14:18 ` haoxintu at gmail dot com
  2020-07-08 18:39 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Haoxin Tu from comment #1)
> Hi, there.
> 
> I guess I shouldn't use C-Reduce to reduce my ICE on invalid code cases.
> After using C-Reduce, the cases are more like a "garbage" code.

You can still use creduce (I do), but it's good to try adding missing
parens/braces and similar to make the code more sensible.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570
  2020-06-29 16:24 [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570 haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2020-07-08 14:05 ` mpolacek at gcc dot gnu.org
@ 2020-07-08 14:18 ` haoxintu at gmail dot com
  2020-07-08 18:39 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-08 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Haoxin Tu <haoxintu at gmail dot com> ---
(In reply to Marek Polacek from comment #3)

> You can still use creduce (I do), but it's good to try adding missing
> parens/braces and similar to make the code more sensible.

Yes, you are right. Thanks for you advise, and I am doing this like what you
said.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570
  2020-06-29 16:24 [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570 haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2020-07-08 14:18 ` haoxintu at gmail dot com
@ 2020-07-08 18:39 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-07-08

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-08 18:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 16:24 [Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570 haoxintu at gmail dot com
2020-07-03  3:14 ` [Bug c++/95972] " haoxintu at gmail dot com
2020-07-08 12:40 ` haoxintu at gmail dot com
2020-07-08 14:05 ` mpolacek at gcc dot gnu.org
2020-07-08 14:18 ` haoxintu at gmail dot com
2020-07-08 18:39 ` mpolacek at gcc dot gnu.org

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).