C++ Logo

std-proposals

Advanced search

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

From: Alejandro Colomar <une+cxx_std-proposals_at_[hidden]>
Date: Tue, 10 Feb 2026 21:01:34 +0100
Hi Thiago,

On 2026-02-10T11:46:34-0800, Thiago Macieira wrote:
> On Tuesday, 10 February 2026 11:36:52 Pacific Standard Time Alejandro Colomar
> wrote:
> > If misuse is easy, it will happen. We could perfectly design these
> > tools so that misuse is harder. In C terms, misusing [[reproducible]]
> > should result in a constraint violation. I think this is viable. The
> > attribute would have to be part of the function type, to make it
> > propagate well, and the function could not contain any uses of volatile
> > lvalues, any static-storage-duration objects, nor any
> > non-[[reproducible]] function calls.
> >
> > A language that puts the burden on the programmer is just badly
> > designed.
>
> I'm not passing judgement on the benefit of having the diagnostics. We well
> should.
>
> But from the point of view of the language, we don't have to, for an
> attribute. If you make it part of the function type and make it ill-formed to
> violate the constraints, that's a different story.

Yup, that's the point. (Ignorable) attributes are very dangerous
features as they are now, and could be turned into safety measures with
very little change. But that change requires making them part of the
actual language and type system.


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>

Received on 2026-02-10 20:01:42