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

2025-03-08


2987. Remove dilapidated wording from static_cast

Section: 7.6.1.9  [expr.static.cast]     Status: open     Submitter: Brian Bi     Date: 2025-01-22

There is some ancient non-operational wording in 7.6.1.9 [expr.static.cast]. It should be removed.

Possible resolution:

  1. Remove in 7.6.1.9 [expr.static.cast] paragraph 1 as follows:

    The result of the expression static_cast<T>(v) is the result of converting the expression v to type T. If T is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if T is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue. The static_cast operator shall not cast away constness (7.6.1.11 [expr.const.cast]).
  2. Remove 7.6.1.9 [expr.static.cast] paragraph 6:

    Otherwise, the inverse of a standard conversion sequence (7.3 [conv]) not containing an lvalue-to-rvalue (7.3.2 [conv.lval]), array-to-pointer (7.3.3 [conv.array]), function-to-pointer (7.3.4 [conv.func]), null pointer (7.3.12 [conv.ptr]), null member pointer (7.3.13 [conv.mem]), boolean (7.3.15 [conv.bool]), or function pointer (7.3.14 [conv.fctptr]) conversion, can be performed explicitly using static_cast. A program is ill-formed if it uses static_cast to perform the inverse of an ill-formed standard conversion sequence. [Example 2:
      struct B { };
      struct D : private B { };
      void f() {
      static_cast<D*>((B*)0);
      static_cast<int B::*>((int D::*)0);
      }
    
    end example]
  3. Change in 7.6.1.9 [expr.static.cast] paragraph 7:

    The Otherwise, the lvalue-to-rvalue (7.3.2 [conv.lval]), array-to-pointer (7.3.3 [conv.array]), and function-to-pointer (7.3.4 [conv.func]) conversions are applied to the operand, and the conversions that can be performed using static_cast are listed below. No other conversion can be performed using static_cast. Such a static_cast is subject to the restriction that the explicit conversion does not cast away constness (7.6.1.11 [expr.const.cast]), and the following additional rules for specific cases:
  4. Remove 7.6.1.9 [expr.static.cast] paragraph 14:

    No other conversion can be performed using static_cast.