Bug 67021 - [c++-concepts] ICE in finish_member_declaration
Summary: [c++-concepts] ICE in finish_member_declaration
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: c++-concepts
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-26 19:09 UTC by Casey Carter
Modified: 2015-07-30 05:49 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-07-30 00:00:00


Attachments
Test case (309 bytes, text/plain)
2015-07-26 19:09 UTC, Casey Carter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Casey Carter 2015-07-26 19:09:54 UTC
Created attachment 36062 [details]
Test case

This program:

#include <type_traits>

template <class...>
struct all_same { static constexpr bool value = true; };
template <class T, class...Rest>
struct all_same<T, T, Rest...> : all_same<T, Rest...> {};
template <class T, class U, class...Rest>
struct all_same<T, U, Rest...> { static constexpr bool value = false; };

template <class...Us>
concept bool Same() {
  return all_same<Us...>::value;
}

template <class R>
using ValueType = int;

template <class I>
concept bool A() {
  return requires (I& i) {
    requires Same<ValueType<I>, ValueType<decltype(i++)>>();
  };
}

template <A>
  requires false
constexpr bool f() { return false; }
template <A>
constexpr bool f() { return true; }

int main() {
  static_assert(f<int>());
}

ICEs with:

~/concept-gcc/bin/g++ -std=gnu++1z foo3.cpp -c
foo3.cpp: In instantiation of ‘struct all_same<ValueType<I>, ValueType<decltype ((i ++))> >’:
foo3.cpp:29:18:   required from here
foo3.cpp:8:56: internal compiler error: in finish_member_declaration, at cp/semantics.c:2862
 struct all_same<T, U, Rest...> { static constexpr bool value = false; };
                                                        ^
0x772373 finish_member_declaration(tree_node*)
	../../gcc/cp/semantics.c:2862
0x68321f instantiate_class_template_1
	../../gcc/cp/pt.c:10028
0x68321f instantiate_class_template(tree_node*)
	../../gcc/cp/pt.c:10237
0x720403 complete_type(tree_node*)
	../../gcc/cp/typeck.c:138
0x7633c4 lookup_member(tree_node*, tree_node*, int, bool, int)
	../../gcc/cp/search.c:1205
0x7c2de9 lookup_qualified_name(tree_node*, tree_node*, bool, bool)
	../../gcc/cp/name-lookup.c:4532
0x65027b tsubst_qualified_id
	../../gcc/cp/pt.c:13402
0x6524db tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../gcc/cp/pt.c:15491
0x64462e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../gcc/cp/pt.c:15092
0x8057df lift_function_definition
	../../gcc/cp/constraint.cc:407
0x80488d lift_requires_expression
	../../gcc/cp/constraint.cc:526
0x80488d lift_expression
	../../gcc/cp/constraint.cc:558
0x805220 normalize_predicate_constraint
	../../gcc/cp/constraint.cc:955
0x805220 normalize_constraint
	../../gcc/cp/constraint.cc:993
0x805508 build_constraints(tree_node*, tree_node*)
	../../gcc/cp/constraint.cc:1096
0x5af175 grokfndecl
	../../gcc/cp/decl.c:7788
0x6208f6 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**)
	../../gcc/cp/decl.c:11202
0x622066 start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*)
	../../gcc/cp/decl.c:13964
0x710ce8 cp_parser_function_definition_from_specifiers_and_declarator
	../../gcc/cp/parser.c:24317
0x710ce8 cp_parser_init_declarator
	../../gcc/cp/parser.c:17632
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.

Here's where things get weird: despite the fact that nothing in the test case refers to any entity in namespace std, removing "#include <type_traits>" results in a correctly compiling program.
Comment 1 Casey Carter 2015-07-28 23:09:14 UTC
The test case no longer ICEs r226327, but it still fails to compile only when <type_traits> is included.
Comment 2 Jason Merrill 2015-07-30 05:28:06 UTC
Author: jason
Date: Thu Jul 30 05:27:34 2015
New Revision: 226381

URL: https://gcc.gnu.org/viewcvs?rev=226381&root=gcc&view=rev
Log:
	DR 1558
	PR c++/67021
	* pt.c (tsubst_decl) [TYPE_DECL]: Clear TYPE_DEPENDENT_P_VALID.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-52.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
Comment 3 Jason Merrill 2015-07-30 05:31:40 UTC
Author: jason
Date: Thu Jul 30 05:31:09 2015
New Revision: 226382

URL: https://gcc.gnu.org/viewcvs?rev=226382&root=gcc&view=rev
Log:
	DR 1558
	PR c++/67021
	* pt.c (tsubst_decl) [TYPE_DECL]: Clear TYPE_DEPENDENT_P_VALID.

Added:
    branches/c++-concepts/gcc/testsuite/g++.dg/cpp0x/alias-decl-52.C
Modified:
    branches/c++-concepts/gcc/cp/pt.c
Comment 4 Jason Merrill 2015-07-30 05:31:58 UTC
Fixed.
Comment 5 Jason Merrill 2015-07-30 05:49:12 UTC
Author: jason
Date: Thu Jul 30 05:48:40 2015
New Revision: 226383

URL: https://gcc.gnu.org/viewcvs?rev=226383&root=gcc&view=rev
Log:
	DR 1558
	PR c++/67021
	* pt.c (tsubst_decl) [TYPE_DECL]: Clear TYPE_DEPENDENT_P_VALID.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/alias-decl-52.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/pt.c