User account creation filtered due to spam.

Bug 49229 - [C++0x][SFINAE] ICE with variadics and depending non-type default parameter
Summary: [C++0x][SFINAE] ICE with variadics and depending non-type default parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-30 11:18 UTC by Daniel Krügler
Modified: 2011-06-17 01:07 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-06-15 17:39:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-05-30 11:18:32 UTC
gcc 4.7.0 20110528 (experimental) in C++0x mode produces an ICE with the following program at the line marked with #:

//-----
extern void* enabler;

template<bool, class = void>
struct enable_if {};

template<class T>
struct enable_if<true, T> {
  typedef T type;
};

template<class... Bn>
struct and_;

template<class B1>
struct and_<B1> : B1 {};

template<class, class>
struct is_same {
  static constexpr bool value = false;
};

template<class T>
struct is_same<T, T> {
  static constexpr bool value = true;
};

template<class... T>
struct S {
  template<class... U,
    typename enable_if<and_<is_same<T, U>...>::value>::type*& = enabler
  >
  S(U...){} // #
};

S<bool> s(0);
//-----

"internal compiler error: tree check: expected tree_vec, have error_mark in comp_template_args, at cp/pt.c:6534"

This bug is possibly related to bug 49225.
Comment 1 Daniel Krügler 2011-05-30 11:26:28 UTC
[Possibly of interest for Paolo as well]

Some observations: Other binary traits that do not lead to a degenerate specialization as is_same does, do not produce this ICE. E.g. given

template<class, class>
struct is_blubb {
  static constexpr bool value = false;
};

template<>
struct is_blubb<bool, bool> {
  static constexpr bool value = true;
};

and a constrained c'tor of S like this

template<class... T>
struct S {
  template<class... U,
    typename enable_if<and_<is_blubb<T, U>...>::value>::type*& = enabler
  >
  S(U...){}
};

S<bool> s(0);

As expected, this program is rejected as expected, but does not produce an ICE.
Comment 2 Paolo Carlini 2011-05-30 11:33:31 UTC
Thanks for your further investigation of these issues, Daniel. I'm not sure to understand what you mean by "degenerate specialization", though. In my experience, a binary trait like is_convertible for example also doesn't work (actually, in the PR I picked is_same only for its simplicity)
Comment 3 Jason Merrill 2011-06-16 22:09:08 UTC
Author: jason
Date: Thu Jun 16 22:09:05 2011
New Revision: 175120

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175120
Log:
	PR c++/49229
	* pt.c (tsubst_decl) [FUNCTION_DECL]: Handle substitution failure.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae26.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jason Merrill 2011-06-17 01:06:52 UTC
Author: jason
Date: Fri Jun 17 01:06:50 2011
New Revision: 175131

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175131
Log:
	PR c++/49229
	* pt.c (tsubst_decl) [FUNCTION_DECL]: Handle substitution failure.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/sfinae26.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/pt.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 5 Jason Merrill 2011-06-17 01:07:26 UTC
Fixed for 4.6.1.