<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Deleted copy constructor, value parameter & move cause incorrect results"
   href="http://llvm.org/bugs/show_bug.cgi?id=20799">20799</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Deleted copy constructor, value parameter & move cause incorrect results
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mrintala43+llvmbugs@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12951" name="attach_12951" title="Code demonstrating the bug">attachment 12951</a> <a href="attachment.cgi?id=12951&action=edit" title="Code demonstrating the bug">[details]</a></span>
Code demonstrating the bug

The attached source code declares a class with a deleted copy constructor and a
move constructor. Such object is passed using std::move() to a function taking
a normal value parameter.

When the program is run, it's clear that the address of the parameter in f and
the address of the object created by the move constructor are not the same (the
object is probably bitwise copied somewhere?):

<span class="quote">> clang++ --version</span >
clang version 3.4.2 (tags/RELEASE_342/final 213642)
Target: x86_64-suse-linux
Thread model: posix
<span class="quote">> clang++ -std=c++11 clangbug.cc 
> ./a.out </span >
z in main: 0x7ffff7298368
Move: 0x7ffff7298360<-0x7ffff7298368
x in f: 0x7ffff7298338

However, if we use the pre-C++11 way to disable copy constructor (<a href="show_bug.cgi?id=20799#c2">comment 2</a>),
then everything works as I expedted:

<span class="quote">> ./a.out </span >
z in main: 0x7fff49f609d8
Move: 0x7fff49f609d0<-0x7fff49f609d8
x in f: 0x7fff49f609d0

Gcc 4.9.1 seems to produce expected results in both cases.

I'm not sure, but when I searched for this bug, I found #18185, which might or
might not have something to do with the case. I ran into this bug when I
debugged a strange behaviour in std::push_heap(), so there's real code
suffering from the problem.</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>