===================================================================
@@ -5611,7 +5611,8 @@ convert_nontype_argument (tree type, tree expr, ts
TREE_TYPE (TREE_TYPE (addr)))))
{
expr = TREE_OPERAND (addr, 0);
- expr_type = TREE_TYPE (expr);
+ expr_type = TREE_TYPE (expr) = cp_build_qualified_type
+ (TREE_TYPE (expr), cp_type_quals (TREE_TYPE (probe_type)));
}
}
}
===================================================================
@@ -0,0 +1,20 @@
+// PR c++/31671
+
+template<int& i> void doit() {
+ i = 0;
+}
+
+template<const int& i> class X {
+public:
+ void foo() {
+ doit<i>(); // { dg-error "cv-qualification|no matching" }
+ }
+};
+
+int i = 0;
+
+X<i> x;
+
+int main() {
+ x.foo();
+}