[Bug c++/38622] operator ?: Does not check identity of types
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Dec 25 15:32:00 GMT 2008
------- Comment #6 from pinskia at gcc dot gnu dot org 2008-12-25 15:30 -------
(In reply to comment #5)
> Let's start from the beginning.
>
> class A{public:int x;A():x(0){};};
> class B:public A{public:int y;B():A(),y(0){};};
> class C:public A{public:int z;C():A(),z(0){};};
>
> B xb;
> C xc;
>
> A& debug1(){
> return (false?xb:xc);} // an error
> It is desirable to remove an error message.
Not really because it is invalid code.
Since there is no xb cannot be converted into C or xc cannot be converted into
B, the code is invalid. The reason why it works when using xa and ab is
because xb can be converted into A& anyways.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38622
More information about the Gcc-bugs
mailing list