<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 - std::copy_n requires non-overlapping inputs"
   href="https://bugs.llvm.org/show_bug.cgi?id=36850">36850</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::copy_n requires non-overlapping inputs
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>t.p.northover@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20096" name="attach_20096" title="Example of unexpected behaviour">attachment 20096</a> <a href="attachment.cgi?id=20096&action=edit" title="Example of unexpected behaviour">[details]</a></span>
Example of unexpected behaviour

Most of the "std::copy*" functions explicitly require their input and output
iterators not to overlap, but std::copy_n doesn't seem to.

However, the implementation of std::copy_n in libc++ forwards to a version of
std::copy which behaves differently than expected from a straightforward
reading of copy_n's effects clause and calls memmove.

This came up on IRC, where Eelis came up with the attached C++ file
demonstrating the difference from a naive copy_n.</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>