Bug 84661 - [8 Regression] internal compiler error: Segmentation fault (strip_array_types())
Summary: [8 Regression] internal compiler error: Segmentation fault (strip_array_types())
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P4 normal
Target Milestone: 9.0
Assignee: Paolo Carlini
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-02 08:42 UTC by Vegard Nossum
Modified: 2021-05-14 10:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-02 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-03-02 08:42:44 UTC
Input:

class {
  &a;
  b(decltype(((a = 0) || ((auto)))))
};

Output:

$ xgcc -x c++ -S -
<stdin>:2:4: error: ISO C++ forbids declaration of 'a' with no type [-fpermissive]
<stdin>:3:28: error: expected primary-expression before 'auto'
<stdin>:3:28: error: expected ')' before 'auto'
<stdin>:3:37: error: expected ')' before '}' token
<stdin>:4:1: internal compiler error: Segmentation fault
0x3155789 crash_signal
        /home/vegard/git/gcc/gcc/toplev.c:325
0x400d828 strip_array_types(tree_node*)
        /home/vegard/git/gcc/gcc/tree.c:7932
0x139c9d0 cp_type_quals(tree_node const*)
        /home/vegard/git/gcc/gcc/cp/typeck.c:9585
0x136f3dc cv_unqualified(tree_node*)
        /home/vegard/git/gcc/gcc/cp/tree.c:1286
0xa4dc38 initialized_type
        /home/vegard/git/gcc/gcc/cp/constexpr.c:2707
0xa4dc38 cxx_eval_outermost_constant_expr
        /home/vegard/git/gcc/gcc/cp/constexpr.c:4794
0xa5b966 maybe_constant_value(tree_node*, tree_node*)
        /home/vegard/git/gcc/gcc/cp/constexpr.c:5044
0xaba942 cp_fully_fold(tree_node*)
        /home/vegard/git/gcc/gcc/cp/cp-gimplify.c:2040
0xec86a3 cp_parser_binary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9298
0xec95aa cp_parser_assignment_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9484
0xecbaca cp_parser_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9653
0xf3833e cp_parser_primary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:5204
0xf7a2eb cp_parser_postfix_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:7028
0xf2e057 cp_parser_unary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:8320
0xec31aa cp_parser_cast_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9088
0xec57d6 cp_parser_binary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9189
0xec95aa cp_parser_assignment_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9484
0xecbaca cp_parser_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9653
0xf7d8a1 cp_parser_decltype_expr
        /home/vegard/git/gcc/gcc/cp/parser.c:14052
0xf7d8a1 cp_parser_decltype
        /home/vegard/git/gcc/gcc/cp/parser.c:14126

$ xgcc --version
xgcc (GCC) 8.0.1 20180301 (experimental)

Built from git c435a9e730c6e8f10da09d58b4fc9aaeb401b0d5 (r258097).

Seems present on 4.9.0 if you pass -std=c++14.

Test case was minimised by C-Reduce.
Comment 1 Marek Polacek 2018-03-02 10:53:32 UTC
Confirmed.
Comment 2 Jakub Jelinek 2018-03-02 11:22:04 UTC
ICEs starting with r208426, before that we rejected it with:
pr84661.C:3:36: error: expected primary-expression before ‘auto’
   void foo (decltype(((a = 0) || ((auto)))));
                                    ^
pr84661.C:3:36: error: expected ‘)’ before ‘auto’
pr84661.C:3:45: error: expected ‘)’ before ‘;’ token
   void foo (decltype(((a = 0) || ((auto)))));
                                             ^
pr84661.C:3:45: error: expected ‘)’ before ‘;’ token
pr84661.C:3:45: error: expected ‘)’ before ‘;’ token
pr84661.C:3:13: error: expected identifier before ‘decltype’
   void foo (decltype(((a = 0) || ((auto)))));
             ^
pr84661.C:3:36: error: expected primary-expression before ‘auto’
   void foo (decltype(((a = 0) || ((auto)))));
                                    ^
pr84661.C:3:36: error: expected ‘)’ before ‘auto’
pr84661.C:3:45: error: expected ‘)’ before ‘;’ token
   void foo (decltype(((a = 0) || ((auto)))));
                                             ^
pr84661.C:3:45: error: expected ‘)’ before ‘;’ token
pr84661.C:3:45: error: expected ‘)’ before ‘;’ token
pr84661.C:3:13: error: expected ‘,’ or ‘...’ before ‘decltype’
   void foo (decltype(((a = 0) || ((auto)))));
             ^

I guess this is a dup of PR84642 and PR84647 though.
Comment 3 Jakub Jelinek 2018-03-02 11:23:04 UTC
Slightly cleaned up testcase, so that it isn't that invalid:

struct S {
  int &a;
  void foo (decltype(((a = 0) || ((auto)))));
};
Comment 4 Jakub Jelinek 2018-10-26 10:23:52 UTC
GCC 6 branch is being closed
Comment 5 Paolo Carlini 2019-03-22 20:47:43 UTC
Mine.
Comment 6 paolo@gcc.gnu.org 2019-03-25 20:44:08 UTC
Author: paolo
Date: Mon Mar 25 20:43:36 2019
New Revision: 269923

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

	PR c++/84661
	PR c++/85013
	* parser.c (cp_parser_binary_expression): Don't call cp_fully_fold
	to undo the disabling of warnings.

/testsuite
2019-03-25  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84661
	PR c++/85013
	* g++.dg/concepts/pr84661.C: New.
	* g++.dg/torture/pr85013.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/concepts/pr84661.C
    trunk/gcc/testsuite/g++.dg/torture/pr85013.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Paolo Carlini 2019-03-25 20:46:51 UTC
Fixed in trunk so far.
Comment 8 Richard Biener 2019-11-14 07:53:21 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 9 Jakub Jelinek 2020-03-04 09:47:06 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 10 Jakub Jelinek 2021-05-14 10:33:02 UTC
The GCC 8 branch is being closed, fixed in GCC 9.1.