Hi Martin,

On Mon, Jan 05, 2026 at 03:15:27PM +0100, Martin Uecker wrote:
[...]
> > 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.

But both GCC and Clang (and every quality compiler, actually; show me
one that doesn't) ignore the C standard in this regard, because the
C standard has an Earthly Demon.  You're ignoring reality.

And after all, you're free to explicitly turn off this diagnostic, but
that's your choice.  Constraint violations aren't hard errors.


Have a lovely day!
Alex

> Martin

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to