Skip to content

CWG2905 [temp.dep.constexpr] value-dependence of noexcept ( *expression* ) #554

@MitalAshok

Description

@MitalAshok

Full name of submitter: Mital Ashok

Reference: [temp.dep.constexpr]

Issue description: Whether the operand of a noexcept operator is type-dependent is not enough to know if the noexcept operator is value-dependent. There are plenty of non-type-dependent expressions where whether or not it is potentially-throwing is dependent.

For example:

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

GCC already treats all of these as value-dependent. Clang treats noexcept(new int(T{})) as a not value-dependent false but the rest of them as value-dependent.

Suggested resolution:

Remove noexcept from [temp.dep.constexpr]p2 so it becomes value-dependent if its operand is value-dependent according to [temp.dep.constexpr]p1

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
[...]
noexcept ( expression )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions