The problem here was that instantiation_dependent_r considered the
instantiated TEMPLATE_ID_EXPR to be type-dependent because it had no
type, rather than unknown_type_node like those built by
lookup_template_function.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 77dfecd59a3f96830d04659b0b710c318adbfa07
Author: Jason Merrill <ja...@redhat.com>
Date: Fri Apr 15 09:18:51 2016 -0400
PR c++/70505
* pt.c (tsubst_baselink): Give the new TEMPLATE_ID_EXPR
unknown_type_node, too.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4a00530..325351f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13666,9 +13666,10 @@ tsubst_baselink (tree baselink, tree object_type,
/* Add back the template arguments, if present. */
if (BASELINK_P (baselink) && template_id_p)
BASELINK_FUNCTIONS (baselink)
- = build_nt (TEMPLATE_ID_EXPR,
- BASELINK_FUNCTIONS (baselink),
- template_args);
+ = build2 (TEMPLATE_ID_EXPR,
+ unknown_type_node,
+ BASELINK_FUNCTIONS (baselink),
+ template_args);
/* Update the conversion operator type. */
BASELINK_OPTYPE (baselink) = optype;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C
new file mode 100644
index 0000000..d63f1cc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C
@@ -0,0 +1,17 @@
+// PR c++/70505
+// { dg-do compile { target c++11 } }
+
+template <class X>
+struct s
+{
+ template <class T>
+ static constexpr T f1(const T x) {return x;}
+ template <class T, T = f1<T>(sizeof(T))>
+ static constexpr T f2(const T x) {return x;}
+ static void f() {s<int>::f2(42);}
+};
+
+int main()
+{
+ s<int>::f();
+}