Bug 84662 - [6/7 Regression] internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in is_bitfield_expr_with_lowered_type, at cp/typeck.c:1944
Summary: [6/7 Regression] internal compiler error: tree check: expected class 'type', ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P2 normal
Target Milestone: 6.5
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-02 09:01 UTC by Vegard Nossum
Modified: 2018-06-25 18:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-02 00:00:00


Attachments
gcc8-pr84662.patch (855 bytes, patch)
2018-03-02 11:36 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vegard Nossum 2018-03-02 09:01:27 UTC
Input:

double b;
a(__attribute__((c(0 && int() - ([] {} && b) || auto))));

Output:

$ xgcc -x c++ -S -
<stdin>:2:31: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in is_bitfield_expr_with_lowered_type, at cp/typeck.c:1944
0x660319 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
        /home/vegard/git/gcc/gcc/tree.c:9388
0x13af08d tree_class_check(tree_node*, tree_code_class, char const*, int, char const*)
        /home/vegard/git/gcc/gcc/tree.h:3255
0x13af08d is_bitfield_expr_with_lowered_type(tree_node const*)
        /home/vegard/git/gcc/gcc/cp/typeck.c:1944
0x13af7f5 cp_perform_integral_promotions(tree_node*, int)
        /home/vegard/git/gcc/gcc/cp/typeck.c:2169
0x13cc321 cp_default_conversion
        /home/vegard/git/gcc/gcc/cp/typeck.c:2138
0x13ce169 cp_build_binary_op(unsigned int, tree_code, tree_node*, tree_node*, int)
        /home/vegard/git/gcc/gcc/cp/typeck.c:4272
0x945247 build_new_op_1
        /home/vegard/git/gcc/gcc/cp/call.c:6013
0x948c36 build_new_op(unsigned int, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int)
        /home/vegard/git/gcc/gcc/cp/call.c:6058
0x1395e6b build_x_binary_op(unsigned int, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int)
        /home/vegard/git/gcc/gcc/cp/typeck.c:4030
0x10f4b6e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:17537
0x10f49f2 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:17524
0x10f4a23 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        /home/vegard/git/gcc/gcc/cp/pt.c:17525
0xa5c07a fold_non_dependent_expr(tree_node*)
        /home/vegard/git/gcc/gcc/cp/constexpr.c:5097
0x105525f build_non_dependent_expr(tree_node*)
        /home/vegard/git/gcc/gcc/cp/pt.c:25295
0x13967bf build_x_binary_op(unsigned int, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int)
        /home/vegard/git/gcc/gcc/cp/typeck.c:4022
0xec7b2b cp_parser_binary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9354
0xec95aa cp_parser_assignment_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:9484
0xed75e4 cp_parser_parenthesized_expression_list
        /home/vegard/git/gcc/gcc/cp/parser.c:7762
0xeda0bb cp_parser_gnu_attribute_list
        /home/vegard/git/gcc/gcc/cp/parser.c:25047
0xeda0bb cp_parser_gnu_attributes_opt
        /home/vegard/git/gcc/gcc/cp/parser.c:24962

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

Built from git c435a9e730c6e8f10da09d58b4fc9aaeb401b0d5 (r258097).

7.3.0 seems fine.

Test case was minimised by C-Reduce.
Comment 1 Marek Polacek 2018-03-02 10:57:56 UTC
Actually this one seems to be fixed.
Comment 2 Jakub Jelinek 2018-03-02 11:23:19 UTC
Started with r230365.
Before it got rejected with
pr84662.C:2:3: error: expected constructor, destructor, or type conversion before ‘(’ token
 a (__attribute__((c(0 && int() - ([] {} && b) || auto))));
   ^
Comment 3 Jakub Jelinek 2018-03-02 11:26:17 UTC
(In reply to Marek Polacek from comment #1)
> Actually this one seems to be fixed.

I can still reproduce with latest trunk.
Comment 4 Jakub Jelinek 2018-03-02 11:36:47 UTC
Created attachment 43544 [details]
gcc8-pr84662.patch

Untested fix.
Comment 5 Jakub Jelinek 2018-03-02 17:08:11 UTC
Author: jakub
Date: Fri Mar  2 17:07:39 2018
New Revision: 258146

URL: https://gcc.gnu.org/viewcvs?rev=258146&root=gcc&view=rev
Log:
	PR c++/84662
	* pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Use
	RETURN instead of return.
	<case POINTER_PLUS_EXPR>: Likewise.
	<case CONVERT_EXPR>: If op0 is error_mark_node, just return
	it instead of wrapping it into CONVERT_EXPR.

	* g++.dg/cpp1y/pr84662.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/pr84662.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2018-03-02 19:11:49 UTC
Fixed on the trunk so far.
Comment 7 Jakub Jelinek 2018-06-22 20:28:36 UTC
Author: jakub
Date: Fri Jun 22 20:28:04 2018
New Revision: 261912

URL: https://gcc.gnu.org/viewcvs?rev=261912&root=gcc&view=rev
Log:
	Backported from mainline
	2018-03-02  Jakub Jelinek  <jakub@redhat.com>

	PR c++/84662
	* pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Use
	RETURN instead of return.
	<case POINTER_PLUS_EXPR>: Likewise.
	<case CONVERT_EXPR>: If op0 is error_mark_node, just return
	it instead of wrapping it into CONVERT_EXPR.

	* g++.dg/cpp1y/pr84662.C: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1y/pr84662.C
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/cp/pt.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 8 Jakub Jelinek 2018-06-25 17:27:25 UTC
Author: jakub
Date: Mon Jun 25 17:26:53 2018
New Revision: 262069

URL: https://gcc.gnu.org/viewcvs?rev=262069&root=gcc&view=rev
Log:
	Backported from mainline
	2018-03-02  Jakub Jelinek  <jakub@redhat.com>

	PR c++/84662
	* pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Use
	RETURN instead of return.
	<case POINTER_PLUS_EXPR>: Likewise.
	<case CONVERT_EXPR>: If op0 is error_mark_node, just return
	it instead of wrapping it into CONVERT_EXPR.

	* g++.dg/cpp1y/pr84662.C: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp1y/pr84662.C
Modified:
    branches/gcc-6-branch/gcc/cp/ChangeLog
    branches/gcc-6-branch/gcc/cp/pt.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 9 Jakub Jelinek 2018-06-25 18:15:26 UTC
Fixed for 6.5 and 7.4+ too.