Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #167356
| From | Kaz Kylheku <480-992-1380@kylheku.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: invalid universal character gives error even after #if 0 |
| Date | 2022-08-31 06:52 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <20220830233859.279@kylheku.com> (permalink) |
| References | <temv38$kie6$1@solani.org> |
On 2022-08-31, Philipp Klaus Krause <pkk@spth.de> 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. > By a quick look at the standard it seems to me that the constraint on > universal character names would be treated the same as e.g. the > constraint on constants having a type and the value being in the > representable range. But I don't think anyone would expect an error on a > long sequence of digits inside an #if 0. Inside an #if 0, a sequence of digits is a pp-number. This is a special category. It doesn't have any constraints on its number of digits and such. C99 said that "A preprocessing number does not have type or a value; it acquires both after a successful conversion (as part of translation phase 7) to a floating constant token or an integer constant token." The situation is different with identifiers. The identifier grammar symbol is shared by preprocessor-token and token. So any constraints that apply to some constituent of an identifier apply whether it is part of an identifier that is either preprocesor-token or a token. When it comes to numbers, the preprocessor-token category has the pp-number, and token has the constant. Only when a pp-number becomes a constant is there are problem with the range of its content. Or something like that. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
invalid universal character gives error even after #if 0 Philipp Klaus Krause <pkk@spth.de> - 2022-08-31 08:28 +0200
Re: invalid universal character gives error even after #if 0 Kaz Kylheku <480-992-1380@kylheku.com> - 2022-08-31 06:52 +0000
Re: invalid universal character gives error even after #if 0 Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-09-13 07:52 -0700
Re: invalid universal character gives error even after #if 0 Siri Cruise <chine.bleu@yahoo.com> - 2022-08-31 02:13 -0700
Re: invalid universal character gives error even after #if 0 Kaz Kylheku <480-992-1380@kylheku.com> - 2022-08-31 16:51 +0000
Re: invalid universal character gives error even after #if 0 Siri Cruise <chine.bleu@yahoo.com> - 2022-08-31 10:57 -0700
Re: invalid universal character gives error even after #if 0 Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-09-13 07:54 -0700
csiph-web