Title
Remove dilapidated wording from static_cast
Status
open
Section
7.6.1.9 [expr.static.cast]
Submitter
Brian Bi

Created on 2025-01-22.00:00:00 last changed 1 month ago

Messages

Date: 2025-03-05.22:41:31

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.
History
Date User Action Args
2025-01-22 00:00:00admincreate