-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsC++20 concepts
Description
Bugzilla Link | 48872 |
Version | trunk |
OS | Linux |
CC | @zygoloid |
Extended Description
As per [defns.signature.friend] in N4861, the signature of a non-template friend function includes a trailing requires-clause, if it is present. Moreover, [over.dcl]/1 states that two function declarations declare different functions if they have different trailing requires-clauses.
The following example fails to compile for Clang (-std=c++2b, 12.0.0 trunk):
#include <iostream>
template<int N>
struct S {
friend void foo(int) requires (N == 1) { std::cout << "1\n"; }
friend void foo(int) requires (N == 2) { std::cout << "2\n"; }
operator int() const { return 0; }
};
int main() {
foo(S<1>{}); // 1
foo(S<2>{});
// error: definition with same mangled
// name '...' as another definition
}
which is arguably incorrect, as the two, separate (by separate requires-clauses) friend declarations (that are also definitions) should not generate the same mangled name.
(Constrained hidden non-template friends was added as per NS US115 of P2103R0; http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p2103r0.html)
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsC++20 concepts
Type
Projects
Status
Done