New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conflict for the result object of a prvalue #4885
Comments
The built-in assignment operator does not create a new object. Plus, the [basic.life] p8 quote does not talk about "result object" of a prvalue at all, it just talks about objects in general. I'm not seeing a conflict. |
Yet [basic.life/8] specifies that object replacement creates a new object: ‘a new object is created at the storage location which the original object occupied’.
Yet [basic.life/8] specifies that object replacement creates (i.e. initializes) a new object, and [basic.lval/5] defines a result object as a new object that is created (i.e. initialized): ‘The result object of a prvalue is the object initialized by the prvalue;’ |
No. [intro.object] p1 lists the situations when objects are created, and assignment is not in the list. So, assignment does not create an object (it just replaces the value of an existing object). |
In that case this sentence in [basic.life/8] is incorrect:
|
It is not incorrect. It is orthogonal to your issue. |
Could you elaborate? |
The precondition in the sentence does not apply. |
Which sentence, which precondition? |
The first part of the precondition does not occur in your example. int i;
i = 1; Feel free to join #standardese at the C++ Slack. There, we can discuss this and whether something might be editorial. |
@maggyero, the sentence reads "If [...] a new object is created..." |
Do you mean that when built-in assignment replaces the value of an existing object, the lifetime of the existing object continues with the new value without interruption, that is without destruction of the existing object and creation of a new object in the same storage location? |
Yes |
Okay so my mental model of objects was wrong. An object is not a stored value as I thought, since its value can change with built-in assignment as you explained. But nor is an object a storage location, since the storage location of an object can be reused deterministically with placement |
Does the right operand
1
(prvalue) of the built-in assignment operator=
ini = 1;
have a result object or not?No according to [basic.lval/5] (bold emphasis mine):
Yes according to [basic.life/8] (bold emphasis mine) since a new object is initialized at the original storage location:
The text was updated successfully, but these errors were encountered: