Date: Wed, 21 Dec 2022 09:29:32 +0200
On Mon, 19 Dec 2022 at 14:51, Sébastien Bini <sebastien.bini_at_[hidden]> wrote:
>
> On Mon, Dec 19, 2022 at 1:11 PM Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>>
>> I don't get it. If we have a new kind of constructor, there is no ABI
>> _break_, since it's just a new constructor. So why aren't you adding
>> such
>> a new constructor for pair?
>>
>> Since this is a semantic facility with semantic guarantees, using
>> attributes here seems like the wrong thing to do.
>
>
> I get your confusion. Let me explain in more detail. Let's say you want to call this relocation constructor with a function parameter as source object. This function parameter was passed by value to the function:
>
> void bar(T);
> void foo(T val)
> { bar(reloc val); }
>
> To simplify, the reloc call here will call the relocation constructor for us. When an object is passed to the relocation constructor, its destructor must not be called. So in the example, foo must not call the destructor of val. However, if foo's ABI is caller-destroy, then foo doesn't have the means of doing that, as it is not in charge of calling the destructor of val in the first place.
The problem goes away if the semantics of destructive move are such
that the destructive-moved-from object is in a state where
destruction is valid but not necessary.
>
> On Mon, Dec 19, 2022 at 1:11 PM Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>>
>> I don't get it. If we have a new kind of constructor, there is no ABI
>> _break_, since it's just a new constructor. So why aren't you adding
>> such
>> a new constructor for pair?
>>
>> Since this is a semantic facility with semantic guarantees, using
>> attributes here seems like the wrong thing to do.
>
>
> I get your confusion. Let me explain in more detail. Let's say you want to call this relocation constructor with a function parameter as source object. This function parameter was passed by value to the function:
>
> void bar(T);
> void foo(T val)
> { bar(reloc val); }
>
> To simplify, the reloc call here will call the relocation constructor for us. When an object is passed to the relocation constructor, its destructor must not be called. So in the example, foo must not call the destructor of val. However, if foo's ABI is caller-destroy, then foo doesn't have the means of doing that, as it is not in charge of calling the destructor of val in the first place.
The problem goes away if the semantics of destructive move are such
that the destructive-moved-from object is in a state where
destruction is valid but not necessary.
Received on 2022-12-21 07:29:44