[LLVMbugs] [Bug 20799] New: Deleted copy constructor, value parameter & move cause incorrect results

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 29 01:51:58 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20799

            Bug ID: 20799
           Summary: Deleted copy constructor, value parameter & move cause
                    incorrect results
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mrintala43+llvmbugs at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12951
  --> http://llvm.org/bugs/attachment.cgi?id=12951&action=edit
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?):

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

However, if we use the pre-C++11 way to disable copy constructor (comment 2),
then everything works as I expedted:

> ./a.out 
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140829/37bbc526/attachment.html>


More information about the llvm-bugs mailing list