<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 - [C++20] Defaulting a comparison operator on second declaration should be diagnosed"
   href="https://bugs.llvm.org/show_bug.cgi?id=51885">51885</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[C++20] Defaulting a comparison operator on second declaration should be diagnosed
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>arthur.j.odwyer@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><a href="https://eel.is/c++draft/class.compare.default#1.sentence-4">https://eel.is/c++draft/class.compare.default#1.sentence-4</a>
<span class="quote">> A definition of a comparison operator as defaulted that appears in a class shall be the first declaration of that function.</span >

IIUC, this sentence is designed to prevent people from default'ing a
"non-hidden" friend, like this:

// <a href="https://godbolt.org/z/6Tdac86TP">https://godbolt.org/z/6Tdac86TP</a>
struct B;
bool operator==(const B&, const B&);
struct B {
    friend bool operator==(const B&, const B&) = default;
};
int main() { B b; return b == b; }

However, Clang trunk does not diagnose any problem with this code. Instead,
Clang quietly pretends that the friend declaration wasn't there at all.

FWIW, GCC also does not diagnose this code, but GCC quietly *accepts* the
friend declaration (so we don't get any undefined symbol for operator== and the
program links fine).</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>