public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113748] New: GCC rejects valid program involving befriending class with name same as typedef
@ 2024-02-03 17:09 jlame646 at gmail dot com
2024-02-03 18:45 ` [Bug c++/113748] " pinskia at gcc dot gnu.org
2024-02-07 9:22 ` jlame646 at gmail dot com
0 siblings, 2 replies; 3+ messages in thread
From: jlame646 at gmail dot com @ 2024-02-03 17:09 UTC (permalink / raw)
To: gcc-bugs
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`.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/113748] GCC rejects valid program involving befriending class with name same as typedef
2024-02-03 17:09 [Bug c++/113748] New: GCC rejects valid program involving befriending class with name same as typedef jlame646 at gmail dot com
@ 2024-02-03 18:45 ` pinskia at gcc dot gnu.org
2024-02-07 9:22 ` jlame646 at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-03 18:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113748
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=21498
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>This should be valid because `friend class C;` befriend a global class named `C`.
Hmm, see PR 21498 ...
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/113748] GCC rejects valid program involving befriending class with name same as typedef
2024-02-03 17:09 [Bug c++/113748] New: GCC rejects valid program involving befriending class with name same as typedef jlame646 at gmail dot com
2024-02-03 18:45 ` [Bug c++/113748] " pinskia at gcc dot gnu.org
@ 2024-02-07 9:22 ` jlame646 at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: jlame646 at gmail dot com @ 2024-02-07 9:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113748
--- Comment #2 from Jason Liam <jlame646 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> >This should be valid because `friend class C;` befriend a global class named `C`.
>
>
> Hmm, see PR 21498 ...
This is ill-formed as explained
here:https://stackoverflow.com/questions/77932976/why-is-a-type-alias-not-allowed-to-be-a-friend-class-name-in-c/77932987#77932987
So gcc is correct here.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-07 9:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-03 17:09 [Bug c++/113748] New: GCC rejects valid program involving befriending class with name same as typedef jlame646 at gmail dot com
2024-02-03 18:45 ` [Bug c++/113748] " pinskia at gcc dot gnu.org
2024-02-07 9:22 ` jlame646 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).