Open MitalAshok opened 2 weeks ago
CWG2905
Actually this seems this is at odds with CWG1074.
Also value-dependence is only for constant expressions, which noexcept
doesn't require (esp. since throwing an exception is not a constant expression)
Also some cases are missing from value-dependence still,
struct X {
virtual void f();
};
template<typename T>
void g() {
X value;
noexcept(dynamic_cast<T&>(value));
}
(I think these are all caught by CWG2066 / CWG2109)
Perhaps noexcept
should not rely on value-dependence at all and be:
noexcept
(
expression)
is value-dependent if expression is an expression involving a template parameter
(See also: CWG1172, making this easier if "instantiation-dependent" was defined)
Yeah. Updated.
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 thenoexcept
operator is value-dependent. There are plenty of non-type-dependent expressions where whether or not it is potentially-throwing is dependent.For example:
GCC already treats all of these as value-dependent. Clang treats
noexcept(new int(T{}))
as a not value-dependentfalse
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