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


1777. Empty pack expansion in dynamic-exception-specification

Section: 14.5  [except.spec]     Status: CD4     Submitter: Richard Smith     Date: 2013-09-24

[Moved to DR at the November, 2014 meeting.]

According to 13.7.4 [temp.variadic] paragraph 6, describing an empty pack expansion,

When N is zero, the instantiation of the expansion produces an empty list. Such an instantiation does not alter the syntactic interpretation of the enclosing construct, even in cases where omitting the list entirely would otherwise be ill-formed or would result in an ambiguity in the grammar.

This leaves open the question of whether something like

  template<typename...T> void f() throw(T...);

should be considered to have a non-throwing exception-specification when T... is empty. The definition in 14.5 [except.spec] paragraph 12 appears to be syntactic regarding dynamic-exception-specifications:

An exception-specification is non-throwing if it is of the form throw(), noexcept, or noexcept(constant-expression ) where the constant-expression yields true. A function with a non-throwing exception-specification does not allow any exceptions.

It seems evident, however, that a dynamic-exception-specification with an empty pack expansion “does not allow any exceptions.”

Proposed resolution (February, 2014):

Change 14.5 [except.spec] paragraph 12 as follows:

A function with no exception-specification or with an exception-specification of the form noexcept(constant-expression ) where the constant-expression yields false allows all exceptions. An exception-specification is non-throwing if it is of the form throw(), noexcept, or noexcept(constant-expression ) where the a dynamic-exception-specification whose set of adjusted types is empty (after any packs are expanded) or a noexcept-specification whose constant-expression is either absent or yields true. A function with a non-throwing exception-specification does not allow any exceptions.