Bug 95193 - [11 Regression] ICE in tsubst_decl, at cp/pt.c:14624
Summary: [11 Regression] ICE in tsubst_decl, at cp/pt.c:14624
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-05-18 20:11 UTC by Arseny Solokha
Modified: 2020-06-03 18:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-05-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2020-05-18 20:11:53 UTC
gcc-11.0.0-alpha20200517 snapshot (g:2b9a271b2d0ba340234a138b7f8289bd7dca2fc5) ICEs when compiling the following testcase, extracted from test/SemaCXX/cxx1z-lambda-star-this.cpp from the clang 10.0.0 test suite, w/ -std=c++17:

struct X {
  void foo() const {
    auto GL1 = [*this](auto a) {
    };

    GL1("abc");
  }
};

% g++-11.0.0 -std=c++17 -c g5fztf1w.cpp
g5fztf1w.cpp: In instantiation of 'X::foo() const::<lambda(auto:1)> [with auto:1 = const char*]':
g5fztf1w.cpp:6:14:   required from here
g5fztf1w.cpp:3:30: internal compiler error: in tsubst_decl, at cp/pt.c:14624
    3 |     auto GL1 = [*this](auto a) {
      |                              ^
0x662811 tsubst_decl
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:14624
0x9fa006 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:17921
0x9f8267 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:18138
0x9f536a instantiate_decl(tree_node*, bool, bool)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:25609
0x926d1a maybe_instantiate_decl
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/decl2.c:5377
0x929558 maybe_instantiate_decl
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/tree.h:3411
0x929558 mark_used(tree_node*, int)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/decl2.c:5573
0x87afa3 build_over_call
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:9077
0x87ff91 build_op_call_1
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:4883
0x87ff91 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:4912
0xa3d83e finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/semantics.c:2692
0x9b3e51 cp_parser_postfix_expression
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:7465
0x9958e9 cp_parser_binary_expression
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:9559
0x99759e cp_parser_assignment_expression
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:9864
0x997963 cp_parser_expression
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:10032
0x99a918 cp_parser_expression_statement
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:11692
0x9a5f73 cp_parser_statement
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:11488
0x9a7828 cp_parser_statement_seq_opt
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:11839
0x9a7908 cp_parser_compound_statement
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:11789
0x9bfcf5 cp_parser_function_body
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:23058
Comment 1 Marek Polacek 2020-05-18 20:22:16 UTC
Started with r11-15-gbcbf334afe091ad7d0f5ffe164299f8730cf41d1
Comment 2 GCC Commits 2020-06-02 19:00:52 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:4b68cb38ddca37a14a6f2f43de3a6d396ee1bc79

commit r11-838-g4b68cb38ddca37a14a6f2f43de3a6d396ee1bc79
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jun 1 17:58:57 2020 -0400

    c++: *this capture in const member fn [PR95193].
    
    Here, the capture proxy for *this is const, but its DECL_VALUE_EXPR is not.
    Don't ICE on this; it's a reasonable difference, since in C++ an rvalue of
    scalar type does not have cv-qualifiers.
    
    gcc/cp/ChangeLog:
    
            PR c++/95193
            * pt.c (tsubst_decl): Relax assert.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/95193
            * g++.dg/cpp1z/lambda-this7.C: New test.
Comment 3 Jason Merrill 2020-06-03 18:11:49 UTC
Fixed.