Path: csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: invalid universal character gives error even after #if 0 Date: Tue, 13 Sep 2022 07:52:20 -0700 Organization: A noiseless patient Spider Lines: 48 Message-ID: <86wna7nx7f.fsf@linuxsc.com> References: <20220830233859.279@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="92872b52a6f682cd3838888a35637fbb"; logging-data="2744000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Lcaa/oGfvz+dElB9OmlvkBLR81RsEU68=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:/LRogLZiVu4TAUYEILKsN31DqGQ= sha1:zsOn0SWOS7RCq43ZuNT0XsW52FQ= Xref: csiph.com comp.lang.c:167673 Kaz Kylheku <480-992-1380@kylheku.com> writes: > On 2022-08-31, Philipp Klaus Krause wrote: > >> I noticed that current gcc and clang give an error on the following: >> >> #if 0 >> \u003a >> #endif >> >> but not on >> >> /* >> \u003a >> */ >> >> While I see that \u003a is a constraint violation, I do not see how it >> follows from the standard that this is a constraint violation even >> inside #if 0. > > #if 0 isn't a commenting mechanism. The material excluded by #if 0 > has to consist of valid preprocessor tokens, so any token-level > constraint violations apply. E.g. you can't have an unterminated > literal in there: > > #if 0 > "unterminated > #endif > > A universal characcter name is a constituent of an identifier, > and an identifier is a kind of preprocessing-token (in the > early translation stages) which later becomes a token. A universal character name _may_ be a constituent of an identifier, but it doesn't have to be. Since the universal character name \u003a does not fall into one of the ranges specified in Annex D.1, it is not allowed in an identifier and therefore is not part of an identifier. Hence it must be treated by the preprocessor on a character-by-character basis, which means the leading \ is a "non-white-space character that cannot be one of the above". Note also that n3047 adds the case each universal-character-name that cannot be one of the above to 6.4 p1 under preprocessing-token, which strengthens the argument.