Title
noexcept-specifier of friend function vs class completeness
Status
open
Section
11.4.1 [class.mem.general]
Submitter
John Spicer

Created on 2021-10-26.00:00:00 last changed 3 weeks ago

Messages

Date: 2021-12-15.00:00:00

Notes from the December, 2021 teleconference:

CWG questioned why the declaration matching couldn't be deferred until the end of the class.

Date: 2021-10-26.00:00:00

According to 11.4.1 paragraph 7, a noexcept-specifier is a complete-class context. This raises an issue when the function is a friend function; for example, consider:

  using T = int;
  struct B {
    friend void g(B b) noexcept(sizeof(b.m) >= 4) { }
    T m = T();
  };
  int main() {
    B b;
    g(b);
  }

For friend declarations you need to be able to decide at the point of declaration whether it matches a prior declaration, and you can't do that if you treat the noexcept-specifier as a complete-class context.

There is implementation divergence in the treatment of this example.

History
Date User Action Args
2022-01-06 00:00:00adminsetmessages: + msg6618
2021-10-26 00:00:00admincreate