https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88103

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |glisse at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Isn't that just because we've actually folded the true ? x : y expressions to x
before handling it?
If I tweak the testcase (below, so that it can't be folded), it started FAILing
with r200821.

struct A {
    A(int);
    A&& foo() && ;
    int i;
};
void free(A&&);

void test_xvalue(A a, bool b, A c){
  //No error
  A&& ref = b? static_cast<A&&>(a) : static_cast<A&&>(c); 

  //No error
  free(b? static_cast<A&&>(a) : static_cast<A&&>(c));

  //Unexpected error: passing A as this discard qualifier
  (b? static_cast<A&&>(a) : static_cast<A&&>(c)).foo();

  //Unexpected error: error cannot bind rvalue reference 
  //                  of type int&& to lvalue of type int
  int&& k=(b? static_cast<A&&>(a) : static_cast<A&&>(c)).i;
}
void test_prvalue(A a, bool b){
  //No error
  A&& ref = b? static_cast<A&&>(a) : 1; 

  //No error
  free(b? static_cast<A&&>(a) : 1);

  //No error
  (b? static_cast<A&&>(a) : 1).foo();

  //No error
  int&& k=(b? static_cast<A&&>(a) : 1).i;
}

Reply via email to