https://bugs.llvm.org/show_bug.cgi?id=48872

            Bug ID: 48872
           Summary: Rejects-valid for overloaded hidden non-template
                    friend functions with mutually exclusive
                    requires-clauses
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: davves...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to