<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Rejects-valid for overloaded hidden non-template friend functions with mutually exclusive requires-clauses"
   href="https://bugs.llvm.org/show_bug.cgi?id=48872">48872</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Rejects-valid for overloaded hidden non-template friend functions with mutually exclusive requires-clauses
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>davveston@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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;
<a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p2103r0.html">http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p2103r0.html</a>)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>