[Bug c++/86184] Shall gcc support this feature?

2018-06-20 Thread zhonghao at pku dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86184

--- Comment #2 from zhonghao at pku dot org.cn ---
(In reply to Jonathan Wakely from comment #1)
> (In reply to zhonghao from comment #0)
> > gcc++ produces errors when compiling the following code:
> 
> I don't see any errors. You didn't say which version of GCC you're using or
> what options you're using, as requested by https://gcc.gnu.org/bugs/

I am sorry. I provide a wrong code sample from the clang bug report. The
correct code sample is:

 #include 

 struct X {
 X() { printf("X(): this=%p\n", this); }
 X(const X& other) { printf("X(const ):this=%p, other=%p\n", this, ); }
 ~X() { printf("~X(): this=%p\n", this); }
 operator bool() { printf("X::operator bool(): this=%p\n", this); return true;
}
 };

 int main() {
 X x = X()? : X();
 }

g++ rejects the above code, and the error message is:
error: lvalue required as unary '&' operand
  X x = X()? : X();

clang++ accepts the code.

[Bug c++/86184] Shall gcc support this feature?

2018-06-18 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86184

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2018-06-18
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
(In reply to zhonghao from comment #0)
> gcc++ produces errors when compiling the following code:

I don't see any errors. You didn't say which version of GCC you're using or
what options you're using, as requested by https://gcc.gnu.org/bugs/