C++ Logo

std-proposals

Advanced search

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

From: Alejandro Colomar <une+cxx_std-proposals_at_[hidden]>
Date: Fri, 13 Feb 2026 13:18:12 +0100
Hi Simon,

On 2026-02-13T07:03:18+0100, Simon Schröder via Std-Proposals wrote:
>
>
> > On Feb 10, 2026, at 8:06 PM, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:
> >
> > On Tuesday, 10 February 2026 10:55:23 Pacific Standard Time Alejandro Colomar
> > via Std-Proposals wrote:
> >> But [[comp::attr]] has never been ignorable. That ship has not sailed
> >> yet.
> >
> > Yes they have and are. If I put a [[gnu::noclone]] attribute on a function and
> > compile with Clang, it just tells me:
> >
> > warning: unknown attribute 'gnu::noclone' ignored; did you mean
> > 'gnu::noinline'?
> >
> One good thing about C++ is that its source code can be portable in
> general. If we require that vendor specific attributes cause a
> compiler error we are forced to use macros instead.

Why would we require errors? Nothing in the language other than
obviously #error and static_assert() cause hard errors.

> Sure, we might
> not be able to link to a library compiled with a different compiler
> that supports the attribute. But, as long as we compile everything
> with the same compiler, it should work (in 99% of the cases) even if
> we ignore attributes. We cannot require that msvc supports all gnu
> attributes whenever new ones are introduced. In order to avoid this
> we have a standard to define all attributes that should (but don’t
> have to) be supported by every compiler. I believe that it is
> sufficient to provide a diagnostic for foreign attributes and not
> apply them.

That's precisely what an ill-formed program is (in C, a constraint
violation):

 4.1.1p8:

 A conforming implementation may have extensions
 (including additional library functions),
 provided they do not alter
 the behavior of any well-formed program.
 Implementations are required to diagnose programs
 that use such extensions
 that are ill-formed according to this document.
 Having done so, however,
 they can compile and execute such programs.

This is precisely what the diagnostic you've seen looks like.


Have a lovely day!
Alex

> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

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

Received on 2026-02-13 12:18:19