<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64300>64300</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Undefined reference to defaulted equality-comparison operator of struct with anonymous nested struct
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          burnpanck
      </td>
    </tr>
</table>

<pre>
    The following struct is comparable at compile-time, but fails to link due to a missing symbol for the comparison operator
(`undefined reference to 'A::operator==(A const&) const'`)
```
struct A {
  bool operator==(const A&rhs) const = default;

  bool a  = false;
  struct {
    bool b  = false;
 };
};
```
See https://godbolt.org/z/r6sfoqaET

This is probably related to the fact that it difficult to spell a comparison operator for the nested struct, as the type of the `rhs` argument has no name. I'm not sure what the standard says about autogenerating comparison operators for nested structs in general, or the anonymous case specifically. GCC decides to delete `A::operator==(const A&) const` due to a missing comparison operator for the anonymous nested struct. Both clang and GCC agree to provide a comparison operator for A if the nested struct is named, even if no `operator==` for that nested struct is explicitly declared.

In any case, I believe a link failure is the least desired case, especially because the linker error message is somewhat misleading in that it directs the attention to the outer struct instead of the nested struct.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VNFy4zYM_Br6BRMPTSWy_aAH36Xu5LnpB4AiZLGhSB8BJXW_vkPacZJL7mY0Y1oCVrvYFZDZHyJRp-6-qbv7Bc4yptzZOccjxv5pYZM7dY8jwZBCSC8-HoAlz72AZ-jTdMSMNhCg1H8-0I34iZT5DnYWGNAHBkkQfHwCN1M5I0yeuUKdJpsCDCmDjHTB85wipCNllJSVvld6p8xGtXqOjgYfyUGmgTLFvsIps96pplzXpua-XGazgz5FFmVaZbav57VqtTLbC3KrL1f9e9G2A7X-dr4DYFMK8Am6gsFOmTaPfEUH1dyDowHnIKq5QHwAQqg1AwamawW8DvXday_19st6tb5_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