C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Named Return Value Optimisation [[nrvo]]

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 10 Feb 2026 13:32:39 +0200
On Tue, 10 Feb 2026 at 13:24, Jan Schultke via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> A potential stepping stone toward "enforced optimizations" would be attributes that result in a warning when an optimization isn't performed, without altering the semantics of the program. This could be generally applied to a few optimizations:
>
> [[nrvo]] would issue a warning when NRVO is not performed for an object.
> [[always_inline]] would issue a warning when a function is not inlined.
> [[tail_call]] would issue a warning when a return statement does not result in a tail call.
>
> This delegates the question of when NRVO, inlining, tail call optimization, and other such things happen to QoI. An implementation could consider [[always_inline]] a hint to inline even on debug builds because it would otherwise result in poor QoI and a warning. The implementation and wording effort for this is low, compared to hard guarantees.

Since when is the existing always_inline a mere hint? And since when
is it a request that emits a mere warning if the compiler fails to do
what it's told
to do by that attribute? I mean other than for indirect calls.

Could we perhaps not reinvent the existing attributes with the same
spelling but with a different meaning?

Received on 2026-02-10 11:32:53