Date: Wed, 9 Jul 2025 20:15:57 +0200
On Mon, Jul 7, 2025 at 7:38 PM Jens Maurer <jens.maurer_at_[hidden]> wrote:
>
>
> On 07.07.25 17:41, Corentin via Core wrote:
> > Hey folks,
> >
> > [[foo(#)]] is a valid attribute in C, but invalid in C++, as # is
> considered a token in C and a preprocessing-operator in C++
> > (The grammar of attributes expects tokens in both languages)
> >
> > Is this divergence intended? It does not seem desirable.
> >
> > Note that there is implementation divergence amongst C++ compilers here,
> Clang accepts in all language modes, GCC rejects in all language modes
> https://godbolt.org/z/Wj5fqdd1x <https://godbolt.org/z/Wj5fqdd1x>
>
> Looks like ## should have the same divergence.
>
yes, the same question applies to all of #, ##, %:, %:%:
>
> Jens
>
>
> > https://eel.is/c++draft/lex.operators#1 <
> https://eel.is/c++draft/lex.operators#1>
> > https://eel.is/c++draft/lex.token#nt:token <
> https://eel.is/c++draft/lex.token#nt:token>
> > https://eel.is/c++draft/dcl.attr#nt:balanced-token <
> https://eel.is/c++draft/dcl.attr#nt:balanced-token>
> >
> > _______________________________________________
> > Core mailing list
> > Core_at_[hidden]
> > Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/core
> > Link to this post: http://lists.isocpp.org/core/2025/07/18326.php
>
>
>
>
> On 07.07.25 17:41, Corentin via Core wrote:
> > Hey folks,
> >
> > [[foo(#)]] is a valid attribute in C, but invalid in C++, as # is
> considered a token in C and a preprocessing-operator in C++
> > (The grammar of attributes expects tokens in both languages)
> >
> > Is this divergence intended? It does not seem desirable.
> >
> > Note that there is implementation divergence amongst C++ compilers here,
> Clang accepts in all language modes, GCC rejects in all language modes
> https://godbolt.org/z/Wj5fqdd1x <https://godbolt.org/z/Wj5fqdd1x>
>
> Looks like ## should have the same divergence.
>
yes, the same question applies to all of #, ##, %:, %:%:
>
> Jens
>
>
> > https://eel.is/c++draft/lex.operators#1 <
> https://eel.is/c++draft/lex.operators#1>
> > https://eel.is/c++draft/lex.token#nt:token <
> https://eel.is/c++draft/lex.token#nt:token>
> > https://eel.is/c++draft/dcl.attr#nt:balanced-token <
> https://eel.is/c++draft/dcl.attr#nt:balanced-token>
> >
> > _______________________________________________
> > Core mailing list
> > Core_at_[hidden]
> > Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/core
> > Link to this post: http://lists.isocpp.org/core/2025/07/18326.php
>
>
Received on 2025-07-09 18:16:15