<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 - Trivial copy assignment operator overwrites members not being copied"
   href="https://bugs.llvm.org/show_bug.cgi?id=37038">37038</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Trivial copy assignment operator overwrites members not being copied
          </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>Keywords</th>
          <td>miscompilation
          </td>
        </tr>

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

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

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

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

        <tr>
          <th>Reporter</th>
          <td>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following, the operator= used by Q's defaulted copy assignment operator
for the "d" subobject is a copy assignment operator of B: that is, it does not
copy the "b0" member of "d".
The expected behaviour is observed when Q's copy assignment operator is
explicitly defaulted after its first declaration, but not if it is explicitly
defaulted on its first declaration.

### SOURCE (<stdin>):
extern "C" void abort(void);
struct B0 { int b0; };

struct B {
  B &operator=(const B &) = default;
  int x;
};

struct D : B0, B {
  using B::operator=;
private:
  D &operator=(const D &) && = default;
};

struct Q {
  Q &operator=(const Q &) = default;
  D d;
};
//Q &Q::operator=(const Q &) = default;

Q qa, qb;
int main(void) {
  qb.d.b0 = 42;
  qb = qa;
  if (qb.d.b0 != 42) abort();
}


### COMPILER INVOCATION:
clang++ -xc++ -std=c++2a -o inhtrivcpyassn -


### INVOCATION AND OUTPUT OF RESULTING EXECUTABLE:
<span class="quote">> ./inhtrivcpyassn; printf '(rc=%d)\n' "$?"</span >
Aborted                 ./inhtrivcpyassn
(rc=134)


### EXPECTED RUN OUTPUT:
(rc=0)


### COMPILER VERSION INFO (clang++ -v):
clang version 7.0.0 (<a href="https://github.com/llvm-mirror/clang.git">https://github.com/llvm-mirror/clang.git</a>
f38834898ad991aec557e2a609c6b7c3b288bf10)
(<a href="https://github.com/llvm-mirror/llvm.git">https://github.com/llvm-mirror/llvm.git</a>
433eb70569ee6379cdd5181e72b9193fdb0a39dd)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64</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>