C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] [+externe Mail+] Re: [isocpp-core] Ignorability of attributes: draft wording, and concern about __has_c_attribute

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 8 Feb 2023 22:18:15 +0200
On Wed, 8 Feb 2023 at 21:57, Uecker, Martin via Liaison
<liaison_at_[hidden]> wrote:

> But testing for an attribute where then only syntax
> is checked by the compiler seems completely useless
> to me. I was asking for an example where this make
> sense, because I could not come up with one.
>
> So is there one?

Yes. Gasper Azman (pardon the lack of proper accentuations on s and z)
explained it:

You have 11 compilers, and one of them will just never report "I do
useful things as a response to your attribute."
You don't care, the 10 compilers cover your needs, and the 1 remaining
one will be an oddball. Once you are confident
that the 10 compilers do the useful thing and are not going to remove
that functionality, and the oddball accepts
your code, you remove the macrodetection of the attribute. (*)

(*) Consider [[assume]]. The 10 compilers report whether they do
optimizations based on assumption attributes,
and the one doesn't matter because it's targeting an emulator where
you don't run all that fast anyway. Once the
10 customer-hardware-targeting compilers say "I optimize based on
assumptions", and the oddball says "I parse
assumption attributes", you no longer need to feature-detect the attribute.

Received on 2023-02-08 20:18:29