+2007-10-31 Christian Bruel <christian.bruel@st.com>
+ Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/19531
+ * cp/typeck.c (check_return_expr): Don't set named_return_value_okay_p
+ if retval is volatile.
+
2007-10-30 Jakub Jelinek <jakub@redhat.com>
PR c++/33616
function. */
&& same_type_p ((TYPE_MAIN_VARIANT (TREE_TYPE (retval))),
(TYPE_MAIN_VARIANT
- (TREE_TYPE (TREE_TYPE (current_function_decl))))));
+ (TREE_TYPE (TREE_TYPE (current_function_decl)))))
+ /* And the returned value must be non-volatile. */
+ && ! TYPE_VOLATILE (TREE_TYPE (retval)));
if (fn_returns_value_p && flag_elide_constructors)
{
+2007-10-31 Christian Bruel <christian.bruel@st.com>
+
+ PR c++/19531
+ * g++.dg/opt/nrv8.C: New.
+
2007-10-30 Jakub Jelinek <jakub@redhat.com>
PR c++/33709
--- /dev/null
+// PR optimization/19531
+// forbids NRV on volatile return value.
+// { dg-options -O2 }
+// { dg-do run }
+
+extern "C" { void abort(); }
+
+struct A
+{
+ int d;
+
+ A () { d = 123; }
+ A (const A & o) { d = o.d; }
+ A (volatile const A & o) { d = o.d + 2; }
+};
+
+A bar()
+{
+ volatile A l;
+ return l;
+}
+
+main()
+{
+ A a = bar ();
+
+ if (a.d != 125)
+ abort();
+
+ return 0;
+}