]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/52988 (std::async not executed on function returning nullptr_t)
authorJason Merrill <jason@redhat.com>
Mon, 25 Jun 2012 20:37:14 +0000 (16:37 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 25 Jun 2012 20:37:14 +0000 (16:37 -0400)
PR c++/52988
* typeck.c (decay_conversion): Don't discard side-effects from
expressions of nullptr_t.

From-SVN: r188953

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nullptr28.C [new file with mode: 0644]

index 87870dfcf745a45949d1a4169c36444636d00556..c538751167983c7f255f5e3ea06dcc14fb84a8e7 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52988
+       * typeck.c (decay_conversion): Don't discard side-effects from
+       expressions of nullptr_t.
+
 2012-04-04  Steve Ellcey <sje@cup.hp.com>
 
        Backported from mainline.
index deb895111b625681c58f1bb518bd4b58e4bbe8db..b2a08a3b9e8cb3c560d1bddea142fe4d3b290f01 100644 (file)
@@ -1822,7 +1822,7 @@ decay_conversion (tree exp)
   if (error_operand_p (exp))
     return error_mark_node;
 
-  if (NULLPTR_TYPE_P (type))
+  if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp))
     return nullptr_node;
 
   /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
index a4fb57c915cb7d209058bfe9795ac153bee50b91..33920f8651a2faa7e8274359863e1b5ee7390362 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52988
+       * g++.dg/cpp0x/nullptr28.C: New.
+
 2012-06-19  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * gcc.dg/stack-usage-1.c: Remove dg-options line for sh targets
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr28.C b/gcc/testsuite/g++.dg/cpp0x/nullptr28.C
new file mode 100644 (file)
index 0000000..05fbe57
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-do run { target c++11 } }
+
+typedef decltype(nullptr) nullptr_t;
+
+int i;
+nullptr_t n;
+const nullptr_t& f() { ++i; return n; }
+
+nullptr_t g() { return f(); }
+
+int main()
+{
+  g();
+  if (i != 1)
+    __builtin_abort ();
+}