C++ Logo

std-proposals

Advanced search

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

From: Barry Revzin <barry.revzin_at_[hidden]>
Date: Mon, 9 Feb 2026 18:38:26 -0600
On Mon, Feb 9, 2026 at 5:53 PM Thiago Macieira <thiago_at_[hidden]> wrote:

> On Monday, 9 February 2026 15:40:49 Pacific Standard Time Barry Revzin
> wrote:
> > And that reason has nothing to do with the alleged ignorability of
> > attributes.
> >
> > It was originally [[align(X)]]. It only changed because C didn't have
> > attributes yet and was pursuing _Align(...), so C and C++ unified on
> > _Alignas(...) and alignas(...). That's why it's in the spot it's at, and
> > why [dcl.align] (not alignas) is under [dcl.attr].
> >
> > We didn't need a new keyword for aligning anymore than we needed a new
> > keyword for overriding.
>
> And yet, neither override, final, nor alignas are ignorable. The program
> is
> ill-formed if it overrides a non-virtual or final virtual, so it shouldn't
> be
> an attribute. And no one is going to argue we needed a syntax compatible
> with
> C for those.


And yet, [[override]] and [[final]] were originally attributes too. They
weren't changed to be keywords because of C compatibility, but they weren't
changed because of ignorability either, they were changed because:

Several experts have lamented the solution, saying that it uses attributes
> for semantic effects and that the language shouldn’t use such semantic
> effects itself as that sets a bad example. Furthermore many people consider
> the attributes ugly.


Which isn't much of an argument, but that's all there was.

Moreover, override and final are... extremely ignorable. All they do is
request a diagnostic for otherwise well-formed code. That's the same niche
as [[nodiscard]] and [[deprecated]]. If those are bad attributes, then
there does not even exist a good attribute. It was a purely arbitrary
change.

At least with override and final we kept a good name, unlike align which we
had to change to alignas, but otherwise all these changes just made the
language more complex for no benefit.

Barry

Received on 2026-02-10 00:38:42