C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Stop gap required for NRVO until Anton's paper is assimilated

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 11 Jul 2024 15:26:10 -0700
On Thursday 11 July 2024 13:55:05 GMT-7 Tiago Freire via Std-Proposals wrote:
> My question is, if it could nrvo why would you stop it?
>
> Telling it that it could nrvo is useless if the compiler cannot figure out
> how to do it. And if it can figure out how to do it, why would you not want
> it to?

No one is asking that. You're reading too much into the request and came up
with a corollary that doesn't follow.

We're asking for a syntax to make it either ill-formed or at least a
diagnostic when the syntax is used and NRVO is not permitted. The corollary of
that is if NRVO is not permitted and you don't mark it, nothing changes.

> Telling it that it could, but not when it could is just going to lead to
> different compilers deciding on different rules on how to do it, making
> code not portable.

Agreed. We need to have some rules so code can rely on them.

> But if you have the rules, there's no need to tell it,
> why shouldn’t you get that optimization by default?

See other replies, especially Sebastian's.

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

Received on 2024-07-11 22:26:13