C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [Draft Proposal] Required attribute syntax

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 06 May 2023 22:03:13 -0700
On Saturday, 6 May 2023 16:32:49 PDT Marcin Jaczewski wrote:
> My whole point is I do not want to know this, I only want to guarantee
> that ALL compilers that
> target the same ABI have exactly the same result, and best would be if
> it would work
> same on old, current and future compilers.

And you have any evidence that they don't? That's the point: the ABI decides
what should happen and all compilers adhere to it. If a compiler decides they
can't yet implement the necessary ABI rules, then they should simply say they
don't support this attribute yet.

And my point is that the MSVC ABI decided that this attribute means nothing.
All compiler do adhere to it.

> Now if I use NUA, I do not have this, as some old MSVC compilers miss
> report availability of NUA,
> and GCC MinGW compiles it making output incompatible with one from old MSVC.

MSVC's C++ ABI is not compatible with GCC's at all. You can only compare
compilers that follow the ABI.

> And this is very bad.

I agree this attribute shouldn't have been one. But I don't see what the
problem is right now.

> More I think about this, the more I think that Sebastian's solution
> with `!!` is the correct one.
> The Best part is that `[[!!xxx]]` is ill-formed C++ code today. This
> means we have for free
> protection from miss compiling using older compilers.
> New compilers will recognize it as "required" attribute, and quote
> from standard point:

I disagree, but only mildly. Can you give three examples where this would be
useful? NUA doesn't count because it's not a good attribute in the first place
and, if we're going to change the language, we may as well fix this (IMO)
mistake.

> I think all attributes like `[[no_unique_address]]`,
> `[[trivially_relocatable]]` or potential `[[tail_call]]`,
> `[[fastcall]]` should only
> be allowed in form `[[!!no_unique_address]]`,
> `[[!!trivially_relocatable]]`, `[[!!tail_call]]`, `[[!!fastcall]]`.
> As ignoring any of them could cause a lot of UB.

Is there any proposal to standardise tail_call or fastcall?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-05-07 05:03:15