commit 1ef4191889beeb8537cd7adc0f4456b4732435f2
Author: Jason Merrill <jason@redhat.com>
Date: Mon Sep 26 18:53:20 2011 -0400
PR c++/45102
* pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out
constant value if we're still in a template.
@@ -13916,7 +13916,7 @@ tsubst_copy_and_build (tree t,
t = tsubst_copy (t, args, complain, in_decl);
/* As in finish_id_expression, we resolve enumeration constants
to their underlying values. */
- if (TREE_CODE (t) == CONST_DECL)
+ if (TREE_CODE (t) == CONST_DECL && !processing_template_decl)
{
used_types_insert (TREE_TYPE (t));
return DECL_INITIAL (t);
new file mode 100644
@@ -0,0 +1,25 @@
+// PR c++/45012
+
+template <bool B, class T=void> struct enable_if;
+
+template <class T>
+struct enable_if<true,T>
+{
+ typedef T type;
+};
+
+enum { RUNTIME = 0 };
+// it compiles with the previous line commented out and the next commented in
+// static const int RUNTIME=0;
+
+template <class T, class U, class EN=void> struct foo;
+
+template <template<int> class V, int M>
+struct foo<V<M>,V<M>, typename enable_if<M==RUNTIME||M==2>::type> {};
+
+template <template<int> class V1, template<int> class V2, int M>
+struct foo<V1<M>,V2<M>, typename enable_if<M==RUNTIME||M==2>::type> {};
+
+template <int M> struct bar {};
+
+foo<bar<2>,bar<2> > x;