<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++2a: unable to set attributes to defaulted member functions"
   href="https://bugs.llvm.org/show_bug.cgi?id=41991">41991</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>c++2a: unable to set attributes to defaulted member functions
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>8.0
          </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>development@jordi.vilar.cat
          </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>The following code, compiled with clang-8 -std=c++2a, fails with:
  error: an attribute list cannot appear here

(it also issues error: only special member functions may be defaulted, but this
is reported in a separated bug report #41989)

#include <compare>

struct type
{
// original
    [[nodiscard]] friend constexpr std::strong_equality operator<=>(const
type&, const type&) noexcept = default;

//  variant #1
//    [[nodiscard]] friend constexpr std::strong_equality operator<=>(const
type&, const type&) noexcept;

// variant #2
//    [[nodiscard]] friend constexpr std::strong_equality operator<=>(const
type&, const type&) noexcept { return std::strong_ordering::equal; }
};

With variant #1, clang complaints with the same error, this time is correct as
attribues for friend declarations are not allowed as per specs.

With variant #2, clang accepts the code with no complaints as the friend
operator is now a definition and attributes are allowed in this case.

With the original variant, clang applies the rule for friend declaration when
in fact it is a (implicit) definition, that is, the friend operator is not
expected to be later defined.</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>