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 23:49:13 +0200
On Wed, 8 Feb 2023 at 23:26, Uecker, Martin
<Martin.Uecker_at_[hidden]> wrote:
> > > No sorry. I still don't get it. Even if
> > > has_attribute changes from 0 to 202003L or
> > > somthing, you would transition from a no warning
> > > scenario to another no warning scenario when
> > > compiling the project hat uses feature detection.
> > >
> > > So you still do not get notified about the
> > > fact that the odd-ball compiler now does not
> > > warn anymore about the attribute.
> >
> > Notified? Right, you don't get notified, but you can just notice
> > yourself that the feature detection is no longer
> > needed, so you can clean up your code by removing it.
>
> But noticing youself (by reading release notes or running
> a test programm) it is not required that __has_c_attribute
> returns non-zero once the compiler starts syntax checking.
> It could just continue to return 0.

Right - it's important to remember that __has_c_attribute does not
need to do this,
we can do this with a separate macro, because this use case isn't what
many of the
users of __has_c_attribute need. I'm merely explaining why *any*
facility that gives this
"does it parse" answer can be useful.

> > And yes, this is a desire of lesser importance and lesser urgency, and
> > doesn't need to be a part of __has_c_attribute or __has_cpp_attribute.
> Worse, changing __has_c_attribute would not even help here.

Indeed, because it wouldn't tell you the answer to the other question.

The way C specifies __has_c_attribute answers both "does it do useful
stuff?" and "does it parse?"
in a manner that's useful. I mean, you don't need the second answer
right now, you'll just write conditional
code and use your fallback branch if the answer to the first question
is "no". That's _good_. It doesn't give you the answer to another
question,
which is "when can I stop worrying about when a particular
implementation stops complaining about the attribute,
regardless of whether it does useful stuff?". :) But that's a
longer-term problem, and the first order of business
is to change C++ to give the useful answer mentioned at the beginning
of this paragraphs, instead of trying to answer the longer-term
problem's question.

Received on 2023-02-08 21:49:26