This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/7503: (x < Y ? X : Y) as an lvalue and assignment


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]