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

            Bug ID: 113748
           Summary: GCC rejects valid program involving befriending class
                    with name same as typedef
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program is rejected by gcc and clang.
https://godbolt.org/z/3K31ev4YT

```
#include <iostream>
#include <type_traits>

class A {    
};

class B {
    using C = A;


    friend class C;  //gcc and clang rejects this but msvc accepts    
};
```
GCC says:
```
<source>:11:18: error: using typedef-name 'using B::C = class A' after 'class'
   11 |     friend class C;  //gcc and clang rejects this but msvc accepts
      |                  ^
<source>:8:11: note: 'using B::C = class A' has a previous declaration here
    8 |     using C = A;
      |           ^
<source>:11:5: error: friend declaration does not name a class or function
   11 |     friend class C;  //gcc and clang rejects this but msvc accepts
      |     ^~~~~~
Compiler returned: 1
```

This should be valid because `friend class C;` befriend a global class named
`C`.

Reply via email to