Bug 84606 - [8 Regression] internal compiler error: Segmentation fault (enclosing_instantiation_of())
Summary: [8 Regression] internal compiler error: Segmentation fault (enclosing_instant...
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: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-02-27 23:14 UTC by Vegard Nossum
Modified: 2018-03-29 08:44 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.3.0
Known to fail: 8.0
Last reconfirmed: 2018-02-27 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-27 23:14:21 UTC
Input:

template<typename>
struct s {
  struct {
    void __attribute__((common([] { struct d }))) g();
  } f;
};

s<int> a {};

Output:

$ xgcc -x c++ -std=c++14 -O3 -c -
<stdin>: In lambda function:
<stdin>:4:46: error: expected unqualified-id before '}' token
<stdin>: In instantiation of 'struct s<int>::<unnamed>':
<stdin>:5:5:   required from 'struct s<int>'
<stdin>:8:8:   required from here
<stdin>:4:33: internal compiler error: Segmentation fault
0x3138779 crash_signal
        /home/vegard/git/gcc/gcc/toplev.c:325
0x104b080 enclosing_instantiation_of
        /home/vegard/git/gcc/gcc/cp/pt.c:12691
0x117abb3 tsubst_function_decl
        /home/vegard/git/gcc/gcc/cp/pt.c:12245
0x11514e5 tsubst_decl
        /home/vegard/git/gcc/gcc/cp/pt.c:12729
0x11034de tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:13624
0x1164e71 lookup_template_class_1
        /home/vegard/git/gcc/gcc/cp/pt.c:8893
0x1174dce lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int)
        /home/vegard/git/gcc/gcc/cp/pt.c:9168
0x1174dce tsubst_aggr_type
        /home/vegard/git/gcc/gcc/cp/pt.c:12074
0x1104a1d tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:13707
0x1155593 tsubst_decl
        /home/vegard/git/gcc/gcc/cp/pt.c:13003
0x11034de tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:13624
0x10c53d1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:16118
0x10ba0da tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:16322
0x10ba0da tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:16322
0x11d759b tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:17057
0x10f3373 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:18346
0x10f1376 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:18027
0x10bb79c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:16838
0x116144f tsubst_attribute
        /home/vegard/git/gcc/gcc/cp/pt.c:10172
0x1171600 apply_late_template_attributes
        /home/vegard/git/gcc/gcc/cp/pt.c:10274


Version:

xgcc (GCC) 8.0.1 20180204 (experimental)

built from git fdae6180ad24fa6303fa046114f3e4b66b8db34d

Version 7.3.0 don't seem to be affected AFAICS.

Test case was reduced by C-Reduce.
Comment 1 Martin Sebor 2018-02-27 23:20:00 UTC
Bisected to r257093 (gcc 8.0.1):

r257093 | jason | 2018-01-26 10:25:23 -0500 (Fri, 26 Jan 2018) | 8 lines

	PR c++/82514 - ICE with local class in generic lambda.

Before that GCC rejected it with:

pr84606.C: In lambda function:
pr84606.C:5:46: error: expected unqualified-id before ‘}’ token
     void __attribute__((common([] { struct d }))) g();
                                              ^
pr84606.C: In instantiation of ‘struct s<int>::<unnamed>’:
pr84606.C:6:5:   required from ‘struct s<int>’
pr84606.C:9:8:   required from here
pr84606.C:5:51: error: wrong number of arguments specified for ‘common’ attribute
     void __attribute__((common([] { struct d }))) g();
                                                   ^
Comment 2 paolo@gcc.gnu.org 2018-03-29 08:44:15 UTC
Author: paolo
Date: Thu Mar 29 08:43:43 2018
New Revision: 258947

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

	PR c++/84606
	* g++.dg/cpp0x/pr84606.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr84606.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 3 Paolo Carlini 2018-03-29 08:44:41 UTC
Already fixed in trunk.