[Bug c++/87605] Ternary uses explicit copy constructor for lvalue-to-rvalue conversion

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 13 17:31:00 GMT 2018


Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-10-13
     Ever confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I agree the copy should not be possible because of the explicit constructor.

EDG also accepts it, but Clang doesn't:

copy.cc:12:25: error: no matching constructor for initialization of 'A'
    const A& b = true ? a : A();
copy.cc:5:5: note: candidate constructor not viable: requires 0 arguments, but
1 was provided
1 error generated.

More information about the Gcc-bugs mailing list