This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/28169] Tertiary operator: object creation and initialization

------- 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

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

          --  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.



bangerth at dealii dot org changed:

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]