C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Unlocking the potential of prvalue & xrvalue

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 05 Sep 2025 23:06:21 -0700
On Friday, 5 September 2025 18:15:02 Pacific Daylight Time organicoman wrote:
> Yes,* a prvalue is certain
> > to end its lifetime inside the body of the callee, while an xrvalue
> > doesn't.

No, it isn't. On the majority of C++ ABIs, temporaries are caller-destructed,
not callee-destructed.

> void foo(T arg); -
> > becomes-> { T arg{}; foo(&arg);}Which calls ~T(), outside the callee
> > body.So if we have a million call site to foo, then there is a million
> > deduplication of ~T().

No, there's no difference from the caller or callee side:
https://godbolt.org/z/T67z4xv4M for the callers
https://godbolt.org/z/76qoPj8Ya for the callees

Note: please use a decent email client that will allow proper quoting. I'm not
going to reply to emails by you again.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Platform & System Engineering

Received on 2025-09-06 06:06:31