Bug 68724 - [5/6/7 Regression] ice in unify, at cp/pt.c:19902
Summary: [5/6/7 Regression] ice in unify, at cp/pt.c:19902
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P4 normal
Target Milestone: 5.5
Assignee: Nathan Sidwell
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2015-12-05 18:36 UTC by John Regehr
Modified: 2016-08-05 20:04 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-12-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2015-12-05 18:36:01 UTC
ICE on invalid code


$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/regehr/z/compiler-install/gcc-r231259-install/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/regehr/z/compiler-source/gcc/configure --prefix=/home/regehr/z/compiler-install/gcc-r231259-install --disable-bootstrap --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 6.0.0 20151204 (experimental) (GCC) 


$ cat hello.cpp
template <typename _Tp, _Tp> struct integral_constant {
} struct : integral_constant < bool, true {
} template <typename _Tp> struct integral_constant < bool, __is_enum(_Tp) {


$ g++ -std=c++11 hello.cpp -w
hello.cpp:2:1: error: expected ‘;’ after struct definition
 } struct : integral_constant < bool, true {
 ^

hello.cpp:2:12: error: parse error in template argument list
 } struct : integral_constant < bool, true {
            ^~~~~~~~~~~~~~~~~

hello.cpp:3:1: error: expected ‘;’ after struct definition
 } template <typename _Tp> struct integral_constant < bool, __is_enum(_Tp) {
 ^

hello.cpp:3:1: error: abstract declarator ‘<anonymous struct>’ used as declaration
hello.cpp:3:34: error: parse error in template argument list
 } template <typename _Tp> struct integral_constant < bool, __is_enum(_Tp) {
                                  ^~~~~~~~~~~~~~~~~

hello.cpp:3:34: error: template argument ‘__is_enum(_Tp)’ involves template parameter(s)
hello.cpp:3:34: internal compiler error: in unify, at cp/pt.c:19902
0x644f9a unify
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:19902
0x644c45 unify
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:19703
0x64759e get_partial_spec_bindings
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:20466
0x63ef8b most_specialized_partial_spec
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:20735
0x64aa17 process_partial_specialization
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:4694
0x64bddf push_template_decl_real(tree_node*, bool)
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:5214
0x64f2b6 push_template_decl
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:5455
0x64f2b6 maybe_process_partial_specialization(tree_node*)
	/home/regehr/z/compiler-source/gcc/gcc/cp/pt.c:961
0x6c6fd4 cp_parser_class_head
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:21401
0x6c6fd4 cp_parser_class_specifier_1
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:20785
0x6c85d9 cp_parser_class_specifier
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:21081
0x6c85d9 cp_parser_type_specifier
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:15391
0x6e568b cp_parser_decl_specifier_seq
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:12343
0x6f2c13 cp_parser_single_declaration
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:25207
0x6f2fea cp_parser_template_declaration_after_parameters
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:24903
0x6f3c14 cp_parser_explicit_template_declaration
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:25134
0x6f3c14 cp_parser_template_declaration_after_export
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:25152
0x6fde39 cp_parser_declaration
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:11710
0x6fc24d cp_parser_declaration_seq_opt
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:11632
0x6fc598 cp_parser_translation_unit
	/home/regehr/z/compiler-source/gcc/gcc/cp/parser.c:4189
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.
Comment 1 Jakub Jelinek 2016-03-14 09:07:30 UTC
Started with r166977.
Comment 2 Nathan Sidwell 2016-03-29 14:51:05 UTC
One can turn it into the syntactically correct:
template <typename _Tp, _Tp>
  struct integral_constant {
  };

  struct X : integral_constant < bool, true >{
  };

template <typename _Tp>
struct integral_constant < bool, __is_enum(_Tp)> {
};

but still get the ICE when unify meets an unexpected TRAIT_EXPR.
Comment 3 Richard Biener 2016-08-03 11:50:31 UTC
GCC 4.9 branch is being closed
Comment 4 Nathan Sidwell 2016-08-05 12:22:18 UTC
Author: nathan
Date: Fri Aug  5 12:21:46 2016
New Revision: 239167

URL: https://gcc.gnu.org/viewcvs?rev=239167&root=gcc&view=rev
Log:
	PR c++/68724
	* pt.c (unify): TRAIT_EXPR is an expr.

	PR c++/68724
	* g++.dg/cpp0x/pr68724.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr68724.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Nathan Sidwell 2016-08-05 12:24:58 UTC
Fixed r239167
Comment 6 Nathan Sidwell 2016-08-05 19:59:08 UTC
Author: nathan
Date: Fri Aug  5 19:58:36 2016
New Revision: 239177

URL: https://gcc.gnu.org/viewcvs?rev=239177&root=gcc&view=rev
Log:
	PR c++/68724
	* pt.c (unify): TRAIT_EXPR is an expr.

	PR c++/68724
	* g++.dg/cpp0x/pr68724.C: New.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/pr68724.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/pt.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 7 Nathan Sidwell 2016-08-05 20:04:58 UTC
Author: nathan
Date: Fri Aug  5 20:04:27 2016
New Revision: 239178

URL: https://gcc.gnu.org/viewcvs?rev=239178&root=gcc&view=rev
Log:
	PR c++/68724
	* pt.c (unify): TRAIT_EXPR is an expr.

	PR c++/68724
	* g++.dg/cpp0x/pr68724.C: New.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/pr68724.C
Modified:
    branches/gcc-6-branch/gcc/cp/ChangeLog
    branches/gcc-6-branch/gcc/cp/pt.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog