Re: C++ PATCH for c++/70744 (wrong-code with x ?: y extension)

2016-04-25 Thread Jason Merrill
On 04/25/2016 11:35 AM, Marek Polacek wrote: On Fri, Apr 22, 2016 at 03:28:27PM -0400, Jason Merrill wrote: On Fri, Apr 22, 2016 at 2:12 PM, Marek Polacek wrote: +cp_stabilize_reference (tree ref) +{ + if (TREE_CODE (ref) == PREINCREMENT_EXPR + || TREE_CODE (ref) ==

Re: C++ PATCH for c++/70744 (wrong-code with x ?: y extension)

2016-04-25 Thread Marek Polacek
On Fri, Apr 22, 2016 at 03:28:27PM -0400, Jason Merrill wrote: > On Fri, Apr 22, 2016 at 2:12 PM, Marek Polacek wrote: > > +cp_stabilize_reference (tree ref) > > +{ > > + if (TREE_CODE (ref) == PREINCREMENT_EXPR > > + || TREE_CODE (ref) == PREDECREMENT_EXPR) > > I think

Re: C++ PATCH for c++/70744 (wrong-code with x ?: y extension)

2016-04-22 Thread Jason Merrill
On Fri, Apr 22, 2016 at 2:12 PM, Marek Polacek wrote: > On Fri, Apr 22, 2016 at 09:43:31AM -0400, Jason Merrill wrote: >> On 04/22/2016 07:50 AM, Marek Polacek wrote: >> >This PR shows that we generate wrong code with the x ?: y extension in case >> >the >> >first operand

Re: C++ PATCH for c++/70744 (wrong-code with x ?: y extension)

2016-04-22 Thread Marek Polacek
On Fri, Apr 22, 2016 at 09:43:31AM -0400, Jason Merrill wrote: > On 04/22/2016 07:50 AM, Marek Polacek wrote: > >This PR shows that we generate wrong code with the x ?: y extension in case > >the > >first operand contains either predecrement or preincrement. The problem is > >that we don't emit

Re: C++ PATCH for c++/70744 (wrong-code with x ?: y extension)

2016-04-22 Thread Jason Merrill
On 04/22/2016 07:50 AM, Marek Polacek wrote: This PR shows that we generate wrong code with the x ?: y extension in case the first operand contains either predecrement or preincrement. The problem is that we don't emit SAVE_EXPR, thus the operand is evaluated twice, which it should not be.

C++ PATCH for c++/70744 (wrong-code with x ?: y extension)

2016-04-22 Thread Marek Polacek
This PR shows that we generate wrong code with the x ?: y extension in case the first operand contains either predecrement or preincrement. The problem is that we don't emit SAVE_EXPR, thus the operand is evaluated twice, which it should not be. While ++i or --i can be lvalues in C++, i++ or i--