commit f0049ff597cdeb2437cc9e39f633843bdb12bcba
Author: Jason Merrill <jason@redhat.com>
Date: Fri Aug 5 11:57:30 2011 -0400
PR c++/49812
* typeck.c (cp_build_unary_op) [POSTINCREMENT_EXPR]: Strip cv-quals.
@@ -5220,6 +5220,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
}
val = boolean_increment (code, arg);
}
+ else if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR)
+ /* An rvalue has no cv-qualifiers. */
+ val = build2 (code, cv_unqualified (TREE_TYPE (arg)), arg, inc);
else
val = build2 (code, TREE_TYPE (arg), arg, inc);
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/49812
+// The call should choose the second f because i++ is an int rvalue.
+
+template <class T> void f(const volatile T& t) { t.i; }
+template <class T> void f(const T&);
+
+int main()
+{
+ volatile int i = 0;
+ f(i++);
+}