From: Jason Merrill Date: Mon, 25 Jun 2012 20:37:14 +0000 (-0400) Subject: re PR c++/52988 (std::async not executed on function returning nullptr_t) X-Git-Tag: releases/gcc-4.6.4~474 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a05069d8ad6ef7c7a7c9a3353c278d5ee91c3290;p=thirdparty%2Fgcc.git re PR c++/52988 (std::async not executed on function returning nullptr_t) PR c++/52988 * typeck.c (decay_conversion): Don't discard side-effects from expressions of nullptr_t. From-SVN: r188953 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 87870dfcf745..c53875116798 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-06-25 Jason Merrill + + PR c++/52988 + * typeck.c (decay_conversion): Don't discard side-effects from + expressions of nullptr_t. + 2012-04-04 Steve Ellcey Backported from mainline. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index deb895111b62..b2a08a3b9e8c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4fb57c915cb..33920f8651a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-06-25 Jason Merrill + + PR c++/52988 + * g++.dg/cpp0x/nullptr28.C: New. + 2012-06-19 Kaz Kojima * 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 index 000000000000..05fbe57b1971 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr28.C @@ -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 (); +}