C++ Logo

std-proposals

Advanced search

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

From: Simon Schröder <dr.simon.schroeder_at_[hidden]>
Date: Fri, 13 Feb 2026 07:03:18 +0100
> 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. 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.

Received on 2026-02-13 06:03:32