Bug 71406 - [7 Regression] ICE on valid C++ code on x86_64-linux-gnu: in finish_class_member_access_expr, at cp/typeck.c:2782
Summary: [7 Regression] ICE on valid C++ code on x86_64-linux-gnu: in finish_class_mem...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P1 normal
Target Milestone: 7.0
Assignee: Nathan Sidwell
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-06-04 00:22 UTC by Zhendong Su
Modified: 2017-01-23 20:20 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-06-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2016-06-04 00:22:04 UTC
The following code causes an ICE when compiled with the current gcc trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes.

This is a regression from 6.1.x. 


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160603 (experimental) [trunk revision 237059] (GCC)
$
$ g++-6.1 -c small.cpp
$ clang++ -c small.cpp
$
$ g++-trunk -c small.cpp
small.cpp: In member function ‘void A<T>::foo()’:
small.cpp:4:35: internal compiler error: in finish_class_member_access_expr, at cp/typeck.c:2782
   void foo () { this->A::template bar <>; }
                                   ^~~~~~
0x7d85ac finish_class_member_access_expr(cp_expr, tree_node*, bool, int)
        ../../gcc-source-trunk/gcc/cp/typeck.c:2782
0x78d7a4 cp_parser_postfix_dot_deref_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:7331
0x78afec cp_parser_postfix_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:6934
0x78990c cp_parser_unary_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:7986
0x7937c7 cp_parser_cast_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:8663
0x793dc5 cp_parser_binary_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:8765
0x7946b0 cp_parser_assignment_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:9053
0x796fa9 cp_parser_expression
        ../../gcc-source-trunk/gcc/cp/parser.c:9220
0x7975cf cp_parser_expression_statement
        ../../gcc-source-trunk/gcc/cp/parser.c:10681
0x7a640b cp_parser_statement
        ../../gcc-source-trunk/gcc/cp/parser.c:10532
0x7a70cc cp_parser_statement_seq_opt
        ../../gcc-source-trunk/gcc/cp/parser.c:10804
0x7a71bf cp_parser_compound_statement
        ../../gcc-source-trunk/gcc/cp/parser.c:10758
0x7a736f cp_parser_function_body
        ../../gcc-source-trunk/gcc/cp/parser.c:20696
0x7a736f cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc-source-trunk/gcc/cp/parser.c:20732
0x7a7e11 cp_parser_function_definition_after_declarator
        ../../gcc-source-trunk/gcc/cp/parser.c:25416
0x7abc30 cp_parser_late_parsing_for_member
        ../../gcc-source-trunk/gcc/cp/parser.c:26256
0x787439 cp_parser_class_specifier_1
        ../../gcc-source-trunk/gcc/cp/parser.c:21570
0x787439 cp_parser_class_specifier
        ../../gcc-source-trunk/gcc/cp/parser.c:21596
0x787439 cp_parser_type_specifier
        ../../gcc-source-trunk/gcc/cp/parser.c:15836
0x79b843 cp_parser_decl_specifier_seq
        ../../gcc-source-trunk/gcc/cp/parser.c:12758
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$


--------------------------------------------


template < typename T >
struct A : T
{ 
  void foo () { this->A::template bar <>; }
};
Comment 1 Jakub Jelinek 2016-06-04 10:17:12 UTC
Started with r236221.
Comment 2 Marek Polacek 2017-01-13 14:42:12 UTC
This one is in the same basket as Bug 71710 / Bug 77508.
Comment 3 Nathan Sidwell 2017-01-23 20:19:39 UTC
Author: nathan
Date: Mon Jan 23 20:19:07 2017
New Revision: 244832

URL: https://gcc.gnu.org/viewcvs?rev=244832&root=gcc&view=rev
Log:
	PR c++/71406 - ICE with scope-ref'd template id exprs
	PR c++/77508
	* typeck.c (finish_class_member_access_expr): Break up SCOPE_REF
	before breaking up TEMPLATE_ID_EXPR.

	PR c++/71406
	PR c++/77508
	* g++.dg/template/pr71406.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/template/pr71406.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Nathan Sidwell 2017-01-23 20:20:33 UTC
Fixed r244832.