public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111079] New: Failing to reject a defaulted/deleted local function definition if it is a friend of a local class
@ 2023-08-19 21:55 janschultke at googlemail dot com
0 siblings, 0 replies; only message in thread
From: janschultke at googlemail dot com @ 2023-08-19 21:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111079
Bug ID: 111079
Summary: Failing to reject a defaulted/deleted local function
definition if it is a friend of a local class
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: janschultke at googlemail dot com
Target Milestone: ---
## Code to Reproduce A (https://godbolt.org/z/ar34vn5dT)
void foo() {
struct A;
bool operator ==(const A&, const A&);
struct A {
friend bool operator ==(const A&, const A&);
};
bool operator ==(const A&, const A&) = default;
}
## Code to Reproduce B (https://godbolt.org/z/sdo9fhacb)
void foo() {
struct A;
bool bar(const A&, const A&);
struct A {
friend bool bar(const A&, const A&);
};
bool bar(const A&, const A&) = delete;
}
## Expected Output
Compiler error.
## Actual Output
<source>: In function 'void foo()':
<source>:7:40: warning: declaration of 'bool operator==(const foo()::A&, const
foo()::A&)' has 'extern' and is initialized
7 | bool operator ==(const A&, const A&) = default;
|
## Explanation
According to [dcl.fct.def.general] p2:
> A function shall be defined only in namespace or class scope.
There is a definition of `operator==` at block scope, which is obviously
invalid. Operator overloads are also considered functions
([over.oper.general]), so they should be subject to the same rules.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-19 21:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-19 21:55 [Bug c++/111079] New: Failing to reject a defaulted/deleted local function definition if it is a friend of a local class janschultke at googlemail 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).