public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111113] New: Cannot define friend function of a local class in namespace scope
@ 2023-08-23  9:16 fchelnokov at gmail dot com
  2023-08-23 17:59 ` [Bug c++/111113] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: fchelnokov at gmail dot com @ 2023-08-23  9:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111113
           Summary: Cannot define friend function of a local class in
                    namespace scope
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program defines friend function of a local class in namespace scope:

auto foo() {
    struct A;
    void bar(const A&);
    struct A { 
        friend void bar(const A&);
    };
    bar(A{});
    return A{};
}

using A = decltype(foo());
void bar(const A&) {}


Both Clang and MSVC permit it, but GCC prints weird errors:

<source>:5:21: error: 'void bar(const foo()::A&)', declared using local type
'const foo()::A', is used but never defined [-fpermissive]
    5 |         friend void bar(const A&);
      |                     ^~~
<source>:5:21: error: 'void bar(const foo()::A&)' used but never defined
<source>:12:6: warning: 'void bar(const A&)' defined but not used

Online demo: https://godbolt.org/z/Yqoeda94x

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-23 23:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-23  9:16 [Bug c++/111113] New: Cannot define friend function of a local class in namespace scope fchelnokov at gmail dot com
2023-08-23 17:59 ` [Bug c++/111113] " pinskia at gcc dot gnu.org
2023-08-23 18:05 ` pinskia at gcc dot gnu.org
2023-08-23 18:10 ` pinskia at gcc dot gnu.org
2023-08-23 18:16 ` pinskia at gcc dot gnu.org
2023-08-23 23:30 ` language.lawyer at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).