This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7503: (x < Y ? X : Y) as an lvalue and assignment
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, moore_mn at cobra dot cs dot mercer dot edu, nobody at gcc dot gnu dot org
- Date: 22 Nov 2002 01:48:46 -0000
- Subject: Re: c++/7503: (x < Y ? X : Y) as an lvalue and assignment
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, moore_mn at cobra dot cs dot mercer dot edu, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Old Synopsis: (x <? Y) = z; // bad behavior
New Synopsis: (x < Y ? X : Y) as an lvalue and assignment
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu Nov 21 17:48:46 2002
State-Changed-Why:
I can still see this. This is the code in question:
-------------------------------------
#include <iostream>
int main() {
int A = 8;
int B = 8;
(A>B ? A:B) = 1;
std::cout << A << " " << B << std::endl;
}
---------------------------------
It outputs "8 8", which is not what one would expect. I
don't know about the exact semantics of ?: as an lvalue,
but the result at least seems counter intuitive.
Same happens with >? and <? operators.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7503