https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764

            Bug ID: 114764
           Summary: noexcept on a friend complains about incomplete type
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dangelog at gmail dot com
  Target Milestone: ---

Testcase:

struct S
{
    S(int) noexcept;

           void f() noexcept(noexcept(S(42)));
    friend void g() noexcept(noexcept(S(42)));
};


https://godbolt.org/z/qn5Gs4M63



GCC 14 trunk rejects with:

<source>:6:43: error: invalid use of incomplete type 'struct S'
    6 |     friend void g() noexcept(noexcept(S(42)));
      |                                           ^
<source>:1:8: note: definition of 'struct S' is not complete until the closing
brace
    1 | struct S
      |        ^
Compiler returned: 1



But that does not seem to be accurate:
https://eel.is/c++draft/class.mem.general#7 says "A complete-class context of a
class (template) is a [...] noexcept-specifier ([except.spec]) [...]  within
the member-specification of the class or class template." and a friend
declaration/definition is a member-specification.

This is possibly related to bug 70077.

For comparison Clang rejects, but MSVC accepts.

Reply via email to