[Bug c++/90313] [7/8/9/10 Regression] Is an assignment elided with gcc7.3 -O2?

2019-08-09 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90313

--- Comment #4 from rsandifo at gcc dot gnu.org  
---
Author: rsandifo
Date: Fri Aug  9 09:37:55 2019
New Revision: 274234

URL: https://gcc.gnu.org/viewcvs?rev=274234=gcc=rev
Log:
Reject tail calls that read from an escaped RESULT_DECL (PR90313)

In this PR we have two return paths from a function "map".  The common
code sets  to the value returned by one path, while the other
path does:

= map (&, ...);

We treated this call as tail recursion, losing the copy semantics
on the value returned by the recursive call.

We'd correctly reject the same thing for variables:

   local = map (, ...);

The problem is that RESULT_DECLs didn't get the same treatment.

2019-08-09  Richard Sandiford  

gcc/
PR middle-end/90313
* tree-tailcall.c (find_tail_calls): Reject calls that might
read from an escaped RESULT_DECL.

gcc/testsuite/
PR middle-end/90313
* g++.dg/torture/pr90313.cc: New test.

Added:
trunk/gcc/testsuite/g++.dg/torture/pr90313.cc
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-tailcall.c

[Bug c++/90313] [7/8/9/10 Regression] Is an assignment elided with gcc7.3 -O2?

2019-08-08 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90313

rsandifo at gcc dot gnu.org  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rsandifo at gcc dot 
gnu.org

--- Comment #3 from rsandifo at gcc dot gnu.org  
---
Mine.

[Bug c++/90313] [7/8/9/10 Regression] Is an assignment elided with gcc7.3 -O2?

2019-08-08 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90313

Martin Liška  changed:

   What|Removed |Added

   Keywords|needs-bisection |
 CC||marxin at gcc dot gnu.org,
   ||rsandifo at gcc dot gnu.org

--- Comment #2 from Martin Liška  ---
Started with r242668.
@Richard S. Can you please take a look?

[Bug c++/90313] [7/8/9/10 Regression] Is an assignment elided with gcc7.3 -O2?

2019-05-03 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90313

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
 Status|UNCONFIRMED |NEW
  Known to work||6.5.0
   Keywords||needs-bisection, wrong-code
   Last reconfirmed||2019-05-03
 Ever confirmed|0   |1
Summary|Is an assignment elided |[7/8/9/10 Regression] Is an
   |with gcc7.3 -O2?|assignment elided with
   ||gcc7.3 -O2?
   Target Milestone|--- |7.5
  Known to fail||7.1.0, 8.3.0, 9.0

--- Comment #1 from Richard Biener  ---
I can consistently reproduce the wrong result with GCC 7+ at -O2 but not at -O0
(or with -fno-elide-constructors).