This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-05-06


2887. Missing compatibility entries for xvalues

Section: C.6.3  [diff.cpp03.expr]     Status: open     Submitter: Jiang An     Date: 2024-04-18

(From submission #528.)

Paper N3055 (A Taxonomy of Expression Value Categories) introduced xvalues. This changed the behavior of well-formed code for typeid and the conditional operator, but corresponding entries in Annex C are missing.

Possible resolution:

  1. Add a new paragraph to C.6.3 [diff.cpp03.expr] as follows:

    Affected subclause: 7.6.1.8 [expr.typeid]
    Change: Evaluation of operands in typeid.
    Rationale: Introduce more rigorous expression value categories.
    Effect on original feature: Valid C++ 2003 code that uses xvalues as operands for typeid may change behavior. For example,
      void f() {
        struct B {
          B() {}
          virtual ~B() { }
        };
    
        struct C { B b; };
        typeid(C().b); // unevaluated in C++03, evaluated in C++11
      }
    
  2. Add a new paragraph to C.6.3 [diff.cpp03.expr] as follows:

    Affected subclause: 7.6.16 [expr.cond]
    Change: Fewer copies in the conditional operator.
    Rationale: Introduce more rigorous expression value categories.
    Effect on original feature: Valid C++ 2003 code that uses xvalues as operands for the conditional operator may change behavior. For example,
      void f() {
        struct B {
          B() {}
          B(const B&) { }
        };
        struct D : B {};
    
        struct BB { B b; };
        struct DD { D d; };
    
        true ? BB().b : DD().d; // additional copy in C++03, no copy or move in C++11
      }