Bug 71710 - [7 Regression] ICE on valid C++11 code with decltype and alias template: in lookup_member, at cp/search.c:1255
Summary: [7 Regression] ICE on valid C++11 code with decltype and alias template: in l...
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-30 04:43 UTC by Zhendong Su
Modified: 2018-10-13 18:05 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.1.0
Known to fail:
Last reconfirmed: 2016-06-30 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-30 04:43:48 UTC
The following C++11 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 20160629 (experimental) [trunk revision 237855] (GCC) 
$ 
$ g++-6.1 -c -std=c++11 small.cpp
$ clang++-3.8 -c -std=c++11 small.cpp
$ 
$ g++-trunk -c -std=c++11 small.cpp
small.cpp: In substitution of ‘template<class> template<int <anonymous> > using T = decltype (((A*)(void)0)->A< <template-parameter-1-1> >::a) [with int <anonymous> = C; <template-parameter-1-1> = <template-parameter-1-1>]’:
small.cpp:5:28:   required from here
small.cpp:4:42: internal compiler error: in lookup_member, at cp/search.c:1255
   template < int > using T = decltype (a);
                                          ^
0x8074d3 lookup_member(tree_node*, tree_node*, int, bool, int)
	../../gcc-source-trunk/gcc/cp/search.c:1255
0x7dc098 finish_class_member_access_expr(cp_expr, tree_node*, bool, int)
	../../gcc-source-trunk/gcc/cp/typeck.c:2824
0x6e52fd tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../gcc-source-trunk/gcc/cp/pt.c:16946
0x6e9c4e tsubst(tree_node*, tree_node*, int, tree_node*)
	../../gcc-source-trunk/gcc/cp/pt.c:13591
0x6f1a37 tsubst_decl
	../../gcc-source-trunk/gcc/cp/pt.c:12369
0x6ea6ce tsubst(tree_node*, tree_node*, int, tree_node*)
	../../gcc-source-trunk/gcc/cp/pt.c:12874
0x7028fd instantiate_template_1
	../../gcc-source-trunk/gcc/cp/pt.c:17483
0x7028fd instantiate_template(tree_node*, tree_node*, int)
	../../gcc-source-trunk/gcc/cp/pt.c:17534
0x6ea664 instantiate_alias_template
	../../gcc-source-trunk/gcc/cp/pt.c:17564
0x6ea664 tsubst(tree_node*, tree_node*, int, tree_node*)
	../../gcc-source-trunk/gcc/cp/pt.c:12901
0x6fe27f lookup_template_class_1
	../../gcc-source-trunk/gcc/cp/pt.c:8422
0x6fe27f lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int)
	../../gcc-source-trunk/gcc/cp/pt.c:8672
0x8176fd finish_template_type(tree_node*, tree_node*, int)
	../../gcc-source-trunk/gcc/cp/semantics.c:3133
0x7a3c34 cp_parser_template_id
	../../gcc-source-trunk/gcc/cp/parser.c:14919
0x7a3eda cp_parser_class_name
	../../gcc-source-trunk/gcc/cp/parser.c:21223
0x79288d cp_parser_qualifying_entity
	../../gcc-source-trunk/gcc/cp/parser.c:6250
0x79288d cp_parser_nested_name_specifier_opt
	../../gcc-source-trunk/gcc/cp/parser.c:5934
0x7a4657 cp_parser_constructor_declarator_p
	../../gcc-source-trunk/gcc/cp/parser.c:25135
0x7a4657 cp_parser_decl_specifier_seq
	../../gcc-source-trunk/gcc/cp/parser.c:12748
0x7aeb35 cp_parser_single_declaration
	../../gcc-source-trunk/gcc/cp/parser.c:25786
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 > struct A
{
  A *a;
  template < int > using T = decltype (a);
  template < int C > T < C > foo ();
};
Comment 1 Martin Liška 2016-06-30 09:00:15 UTC
Confirmed.
Comment 2 Martin Sebor 2016-07-01 22:43:37 UTC
My bisection script points to r236221 as the responsible commit:

r236221 | jason | 2016-05-13 15:18:35 -0400 (Fri, 13 May 2016) | 23 lines

	Fix type-dependence and the current instantiation.

	PR c++/10200
	PR c++/69753
Comment 3 Zhendong Su 2016-09-07 21:44:06 UTC
A related, but simpler test that triggers the same ICE: 


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


template < typename > struct A
{
  A a;
  template < int > using B = decltype (a);
  B < 0 > b;
};
Comment 4 Nathan Sidwell 2017-01-23 20:25:04 UTC
Author: nathan
Date: Mon Jan 23 20:24:32 2017
New Revision: 244833

URL: https://gcc.gnu.org/viewcvs?rev=244833&root=gcc&view=rev
Log:
	PR c++/71710 - template using directive of field
	* pt.c (tsubst_copy_and_build [COMPONENT_REF]): Move FIELD_DECL
	check earlier.

	PR C++/71710
	* g++.dg/template/pr71710.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/template/pr71710.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Nathan Sidwell 2017-01-23 20:25:34 UTC
Fixed r244833.