Bug 84630 - [7 Regression] ICE: TYPE_NAME() used on error_mark_node in tsubst_lambda_expr, at cp/pt.c:17141
Summary: [7 Regression] ICE: TYPE_NAME() used on error_mark_node in tsubst_lambda_expr...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P4 minor
Target Milestone: 8.0
Assignee: Paolo Carlini
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-01 07:24 UTC by Vegard Nossum
Modified: 2019-11-14 11:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.3, 8.0
Known to fail: 7.5.0
Last reconfirmed: 2018-03-01 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-01 07:24:18 UTC
I was quite sure I had submitted this one but I have searched and cannot see it anywhere, my apologies if it turns out to be a duplicate.

Input:

template <typename...> struct c {
  template <const> __attribute__((noinline([] {}))) b() {}
};
c<> a;

Output:

$ xgcc -x c++ -S -
<stdin>:2:13: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive]
<stdin>:2:55: error: ISO C++ forbids declaration of 'b' with no type [-fpermissive]
<stdin>: In member function 'int c< <template-parameter-1-1> >::b()':
<stdin>:2:58: warning: no return statement in function returning non-void [-Wreturn-type]
<stdin>: In instantiation of 'struct c<>':
<stdin>:4:5:   required from here
<stdin>:2:53: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in tsubst_lambda_expr, at cp/pt.c:17141
0x6602e9 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
        /home/vegard/git/gcc/gcc/tree.c:9388
0x11dd0a0 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*)
        /home/vegard/git/gcc/gcc/tree.h:3255
0x11dd0a0 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:17141
0x10f640b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:18479
0x10f408a tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:18168
0x10bfe06 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:16973
0x1164bbf tsubst_attribute
        /home/vegard/git/gcc/gcc/cp/pt.c:10327
0x1174e7c apply_late_template_attributes
        /home/vegard/git/gcc/gcc/cp/pt.c:10428
0x117ef90 tsubst_function_decl
        /home/vegard/git/gcc/gcc/cp/pt.c:12687
0x1184e90 tsubst_template_decl
        /home/vegard/git/gcc/gcc/cp/pt.c:12804
0x1155421 tsubst_decl
        /home/vegard/git/gcc/gcc/cp/pt.c:12906
0x1105c06 tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:13798
0x11e2760 instantiate_class_template_1
        /home/vegard/git/gcc/gcc/cp/pt.c:10743
0x11ef20b instantiate_class_template(tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:11041
0x138b930 complete_type(tree_node*)
        /home/vegard/git/gcc/gcc/cp/typeck.c:136
0xb38193 start_decl_1(tree_node*, bool)
        /home/vegard/git/gcc/gcc/cp/decl.c:5244
0xc1a64f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**)
        /home/vegard/git/gcc/gcc/cp/decl.c:5207
0xfa251c cp_parser_init_declarator
        /home/vegard/git/gcc/gcc/cp/parser.c:19589
0xfa8357 cp_parser_simple_declaration
        /home/vegard/git/gcc/gcc/cp/parser.c:13061
0xfae548 cp_parser_block_declaration
        /home/vegard/git/gcc/gcc/cp/parser.c:12879

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

Built from git fd1990b25777e5f1307eac1447e8fb5fefe747b4 (r258063).

7.3.0 says:

<source>:2:13: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive]
   template <const> __attribute__((noinline([] {}))) b() {}
             ^~~~~
<source>:2:55: error: ISO C++ forbids declaration of 'b' with no type [-fpermissive]
   template <const> __attribute__((noinline([] {}))) b() {}
                                                       ^
<source>:1: confused by earlier errors, bailing out
Compiler returned: 1

Test case was reduced by C-Reduce.
Comment 1 Andrew Pinski 2018-03-01 07:31:17 UTC
Does not look like a regression from 7.x

This:
<source>:1: confused by earlier errors, 

Just means there was an internal error after an normal error has been emitted (with checking disabled or release checking).  The trunk has checking enabled by default.
Comment 2 David Malcolm 2018-03-01 14:59:50 UTC
Confirmed with trunk, 7, 6 (and 5).  Doesn't crash with 4.8.3.

ICE began on this code (with -std=c++11) between r198776 (no ICE) and r198781, with: 
  "unexpected expression ‘<enumerator>’ of kind template_parm_index")

The ICE message changed to
  "tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in tsubst_lambda_expr, at cp/pt.c:16972"
sometime between r257193 and r257199 (probably in r257199).

Fails on trunk here:

#3  tsubst_lambda_expr (t=<lambda_expr 0x7ffff1a1c080>, args=<tree_vec 0x7ffff1a1ad00>, complain=1, 
    in_decl=<function_decl 0x7ffff1a09f00 operator()>) at ../../src/gcc/cp/pt.c:17141

17141	  determine_visibility (TYPE_NAME (type));

where "type" is "error_mark_node" and thus not a type.

On unchecked builds (e.g. 7), this becomes:

#1  0x00000000007b8eea in cxx_eval_constant_expression(constexpr_ctx const*, tree_node*, bool, bool*, bool*, tree_node**) ()
    at ../../src/gcc/cp/constexpr.c:4654

4654		internal_error ("unexpected expression %qE of kind %s", t,
4655				get_tree_code_name (TREE_CODE (t)));
Comment 3 Paolo Carlini 2018-04-17 19:44:44 UTC
Seems easy.
Comment 4 paolo@gcc.gnu.org 2018-04-18 08:04:16 UTC
Author: paolo
Date: Wed Apr 18 08:03:45 2018
New Revision: 259460

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

	PR c++/84630
	* pt.c (tsubst_lambda_expr): Check begin_lambda_type return value
	for error_mark_node.

/testsuite
2018-04-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84630
	* g++.dg/cpp0x/pr84630.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr84630.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Paolo Carlini 2018-04-18 08:04:50 UTC
Fixed in trunk so far.
Comment 6 Jakub Jelinek 2018-10-26 10:22:57 UTC
GCC 6 branch is being closed
Comment 7 Richard Biener 2019-11-14 11:11:07 UTC
Fixed in GCC 8.