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

2024-12-19


2905. Value-dependence of noexcept-expression

Section: 13.8.3.4  [temp.dep.constexpr]     Status: DR     Submitter: Mital Ashok     Date: 2024-06-16

[Accepted as a DR at the November, 2024 meeting.]

(From submission #554.)

The following examples of noexcept-expressions are not specified to be value-dependent, but ought to be, because value-initialization of T might throw an exception.

  template<typename T>
  void f() {
    noexcept(static_cast<int>(T{}));
    noexcept(typeid(*T{}));
    noexcept(delete T{});
  }

Proposed resolution (approved by CWG 2024-11-19):

  1. Change in 13.8.3.4 [temp.dep.constexpr] paragraph 2 as follows:

    Expressions of the following form are value-dependent if the unary-expression or expression is type-dependent or the type-id is dependent:
    sizeof unary-expression
    sizeof ( type-id )
    typeid ( expression )
    typeid ( type-id )
    alignof ( type-id )
    noexcept ( expression )
    
  2. Change in 13.8.3.4 [temp.dep.constexpr] paragraph 3 as follows:

    Expressions of the following form are value-dependent if either the type-id or , simple-type-specifier, or typename-specifier is dependent or the expression or cast-expression is value-dependent or any expression in the expression-list is value-dependent or any assignment-expression in the braced-init-list is value-dependent:
    simple-type-specifier ( expression-listopt )
    typename-specifier ( expression-listopt )
    simple-type-specifier braced-init-list
    typename-specifier braced-init-list
    static_cast < type-id > ( expression )
    const_cast < type-id > ( expression )
    reinterpret_cast < type-id > ( expression )
    dynamic_cast < type-id > ( expression )
    ( type-id ) cast-expression
    
  3. Add a new paragraph before 13.8.3.4 [temp.dep.constexpr] paragraph 5 as follows:

    A noexcept-expression (7.6.2.7 [expr.unary.noexcept]) is value-dependent if its expression involves a template parameter.

    An expression of the form &qualified-id where ...