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

2024-04-18


1740. Disambiguation of noexcept

Section: 14.5  [except.spec]     Status: C++14     Submitter: Richard Smith     Date: 2013-08-13

N3690 comment CA 27

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

There is an ambiguity between a noexcept specifier's optional parenthesized constant-expression and an initializer:

  void f() noexcept;
  void (*p)() noexcept (&f);

Here, we can just about make 9.3.3 [dcl.ambig.res] paragraph 1's rule fit, and say that the (&f) is part of the exception-specification rather than being an initializer. However, this case is much more problematic:

  void (*fp2)() noexcept, (*fp)() noexcept (fp2 = 0);

The (fp = 0) here is unambiguously an initializer, because an assignment-expression cannot syntactically be a constant-expression, although current implementations treat it as an ill-formed part of the exception-specification.

Probably the best approach would be to change 14.5 [except.spec] to say that a ( following noexcept is always treated as being part of the noexcept-specification.

Proposed resolution (September, 2013):

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

...In a noexcept-specification, the constant-expression, if supplied, shall be a constant expression (7.7 [expr.const]) that is contextually converted to bool (7.3 [conv]). A noexcept-specification noexcept is equivalent to noexcept( true). A ( token that follows noexcept is part of the noexcept-specification (and does not commence an initializer (9.4 [dcl.init]).