C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Ignoring attributes

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Mon, 24 Mar 2025 15:36:40 +0100
pon., 24 mar 2025 o 15:03 Andrey Semashev via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
> On 3/24/25 15:26, Marcin Jaczewski via Std-Proposals wrote:
> >
> > If we want not-ignorable attributes it should be explicit and know
> > upfront even if compiler is 10y old.
> > I would suggest change syntax a bit and add `!!` to attribute to mark
> > it required:
> >
> > ```
> > [[!!no_unique_address]] int foo;
> > ```
> >
> > or
> >
> > ```
> > [[!!(gnu::packed, clang::packed)]] class Foo;
> > ```
> >
> > If the compiler does not recognize and support any attribute from this
> > it should break compilation.
>
> This won't work because current compilers are required to ignore such
> attributes.
>
> If you want mandatory attributes, they should use a syntax that is
> invalid with older compilers.

Whole point is that it is invalid now, GCC and Clang fail at parsing it.
They can't ignore that they can't parse correctly.
And when they start parsing this new format, they can obey rules that
standard will impose on `!!`.

After sending previous email I think about this bit more and
come to conclusion that `!!( ... )` should allow `&&` and `||`
as sometimes different compiler attributes could not overlap:

```
[[!!( X::FeatureAB || (Y::FeatureA && Y::FeatureB) ) ]] class A;
```

Now under compiler `X` it require one feature but on compiler `Y` two,
but combination of them make class ABI compatible with compiler `X` output.

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

Received on 2025-03-24 14:36:52