[cfe-dev] invalid-token-paste

James Dennett james.dennett at gmail.com
Wed Jul 18 18:49:41 PDT 2012


On Wed, Jul 18, 2012 at 6:34 PM, Stephan T. Lavavej
<stl at exchange.microsoft.com> wrote:
> [James Dennett]
>> I'd suggest filing a bug against MSVC, but it's not all that important
>> -- MSVC will likely accept the corrected code, as will all conforming
>> compilers.
>
> Technically, N3376 16.3.3 [cpp.concat]/3 "If the result is not a valid preprocessing token, the behavior is undefined." allows VC to do whatever it wants with the bogus code, including accepting it silently.

Agreed, this isn't actually non-conforming, so my phrasing above could
have been more careful.  (It's been UB at least since C++98, which
matches C99 in this respect.  I've not checked other versions of C,
but I'm not aware of any changes in this area.)

> (I would prefer a compiler error.)

So would I, and I consider it a flaw in the standard that this is left
as UB instead of requiring a diagnostic, and a weakness of any
implementation that doesn't diagnose the problem.

Thanks for the clarification.

-- James



More information about the cfe-dev mailing list