C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Relocation in C++

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 02 May 2022 11:10:41 -0700
On Monday, 2 May 2022 06:23:38 PDT Sébastien Bini via Std-Proposals wrote:
> However, as others have pointed it out, this leads to an ABI break.
> Consider:
>
> void sink(T z);
>
> void fwd_to_sink(T y)
> {
> sink(reloc y); // oops
> }
>
> void foo()
> {
> T x;
> fwd_to_sink(reloc x);
> }
>
> In fwd_to_sink, reloc cannot omit the call to the destructor of 'y', as it
> is called by 'foo'.

Then don't allow relocating a function parameter.

Parameters are always destroyed by the caller and this is required by the
standard, not the ABI. Therefore, regular parameters shouldn't be relocatable.

Unless you add a new type of reference, which we don't want.

I'm very skeptical about relocating static or automatic lifetime variables.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2022-05-02 18:10:43