------- Comment #5 from bangerth at dealii dot org  2006-10-12 01:50 -------
gcc is correct. It is true that the result of the ?: operator is
a reference to the Base object of the Derived object created in the
second arm. However, the result is an rvalue, and a constant reference
is initialized with this rvalue. The standard says about this case:

     --  If  the  initializer  expression is an rvalue, with T2 a class
          type, and "cv1 T1" is reference-compatible with "cv2 T2,"  the
          reference is bound in one of the following ways (the choice is
          implementation-defined):

          --  The reference is bound to the object  represented  by  the
              rvalue  (see  _basic.lval_) or to a sub-object within that
              object.

          --  A temporary of type  "cv1 T2"  [sic]  is  created,  and  a
              constructor  is  called  to  copy the entire rvalue object
              into  the  temporary.   The  reference  is  bound  to  the
              temporary or to a sub-object within the temporary.93)

However, there is a related issue, for which I've just opened PR 29437.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28169

Reply via email to