stabilize_expr can't deal with a volatile vector variable; it tries to
stabilize a glvalue with side-effects by storing its address in a
temporary and then dereferencing that, but if the type of the reference
is volatile then that doesn't actually help at all.
In this case, there's a simple solution: force the rhs to be an rvalue
before trying to stabilize it. In that case, stabilize_expr knows it
can just copy the value into a temporary.
Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit 63317e9a0f674e06909cfb31262f7b37631f74e6
Author: Jason Merrill <ja...@redhat.com>
Date: Mon Jan 27 10:37:03 2014 -0500
PR c++/58814
* typeck.c (cp_build_modify_expr): Make the RHS an rvalue before
stabilizing.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b7ece1b..6268f7b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7399,8 +7399,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
side effect associated with any single compound assignment
operator. -- end note ] */
lhs = stabilize_reference (lhs);
- if (TREE_SIDE_EFFECTS (rhs))
- rhs = mark_rvalue_use (rhs);
+ rhs = rvalue (rhs);
rhs = stabilize_expr (rhs, &init);
newrhs = cp_build_binary_op (input_location,
modifycode, lhs, rhs,
diff --git a/gcc/testsuite/g++.dg/ext/vector25.C b/gcc/testsuite/g++.dg/ext/vector25.C
new file mode 100644
index 0000000..6c1f5d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/vector25.C
@@ -0,0 +1,6 @@
+volatile int i __attribute__((vector_size(8)));
+
+void foo()
+{
+ i += i;
+}