[LLVMbugs] [Bug 16993] Assign rvalue to self

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 16 13:04:55 PDT 2014


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

David Rodríguez <dibeas at ieee.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |REOPENED
                 CC|                            |dibeas at ieee.org
         Resolution|INVALID                     |---

--- Comment #5 from David Rodríguez <dibeas at ieee.org> ---
I don't agree with Howard's interpretation.

a = std::move(a);

After evaluation of just the right hand side, only a cast is done. The state of
the object is still guaranteed to be the initial state. If after just
'std::move' the container 'a' was deemed to be in a valid but unspecified state
this would not be a bug, but I don't think that is the case.

Now we are left with the assignment:

a = static_cast<vector<int>&&>(a);

The requirements for that operation are stated in Table 99, in the entry:

a = rv

The "Assertion/note/pre-post-condition" column has as a post condition:

post: a shall be equal to the value that rv had before this assignment.

>From the point of view of 'a' used as the lhs of the expression, the
precondition that "size() > 100" must hold, since that precondition held on the
rhs of the assignment before the operation.

The conflict here is that there are two set of post conditions, one for the
lhs, one for the rhs:

lhs : must hold the value that rhs held before the assignment
rhs : must be in an indeterminate but valid state

If lhs is rhs, those two requirements are met by guaranteeing that, on self
assignment from an rvalue-reference to itself, the container is left
unmodified.

[All the above is ignoring the allocator completely, but I don't think that
matters as that would be an orthogonal issue]

-- 
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/20140416/8d24ec38/attachment.html>


More information about the llvm-bugs mailing list