Am Montag, dem 05.01.2026 um 15:00 +0100 schrieb Alejandro Colomar:
> 
...

> 
> My proposal, as discussed with you, is to add a mandatory diagnostic
> (contraint violation) about the presence of unrecognized attributes.
> Nothing else.
> 
> This indeed matches the default behavior of both GCC and Clang, and
> I expect to also match every other quality compiler.
> 
>       alx@devuan:~/tmp$ cat attr.c 
>       [[attr]]
>       int
>       main(void)
>       {
>               return 0;
>       }
>       alx@devuan:~/tmp$ gcc attr.c 
>       attr.c:1:1: warning: ‘attr’ attribute ignored [-Wattributes]
>           1 | [[attr]]
>             | ^
>       alx@devuan:~/tmp$ clang attr.c 
>       attr.c:1:3: warning: unknown attribute 'attr' ignored
>             [-Wunknown-attributes]
>           1 | [[attr]]
>             |   ^~~~
>       1 warning generated.
> 
> And in compilers that don't want to implement any attributes, it should
> be trivial to emit a diagnostic saying "Attributes are not supported".
> 
> Is that okay to you?

I will keep arguing (and vote) against this.  The reason is that attributes are
syntactically designed and are useful as a language feature that is
forwards-compatible, i.e. programmers can add annotations that can simply
ignored by older C23 compiler (when looking from the future) without having
to use macro wrappers.  I think this is extremely useful in a long-term
perspective, especially with regard to future annotations for safety.
We also  have no other feature like this, and if we invent yet another
feature the oldest compiler to support it would be a future C2Y compiler
and not a C23 compiler.  So let's  please not break attributes for this 
important use case before we even have started to use them properly.


Martin






Reply via email to