<stdint.h>
CC BY, see https://creativecommons.org/licenses/by/4.0
Introduction and OverviewThe C standard differentiates two terms that have surprisingly different meaning:
âinteger constantâ, which describes a certain category of tokens after lexing
âinteger constant expressionâ, which associates special properties to a non-terminal in the grammar
This even leads to confusion in the standard itself, because the definitions of sizeof
and alignof
cyclicly refer to the definition of âinteger constantâ and âinteger constant expressionâ. In other places the term âinteger constantâ is seemingly used with a different meaning than its definition, namely in places where talking about a constant of integer type would be in order.
The goal of this paper is to rename the terms âinteger constantâ, âfloating constantâ, âcharacter constantâ to âinteger literalâ, âfloating literalâ and âcharacter literalâ. A table summarizing these systematic changes can be found towards the end.
Otherwise we also rely on some terminology changes as they are introduced by the paper n3187, in particular for the change of to speak of âconstant sizeof
expressionâ. But this can evidently be changed if that proposal doesnât make it.
This is the case because the long list of cases mixes cases that talk about lexical concepts and others that talk about semantic properties of certain subexpressions. We propose to make these distinctions clearer by talking consistently about âliteralsâ when we address a lexical feature, and talk about ââconstantsââ as a semantik concept that is attached to certain grammatical entities, but which is in general not deducible from local syntactic features.
We propose to make the following changes.
p8 An integer constant expression130) shall have integer type and shall only have operands that are integer constants literals, named constants, and compound literal constants of integer type, character constants literals, constant
sizeof
expressions whose results are integer constants,alignof
expressions, and floating literals, named constants, or compound literal constants of arithmetic type that are the immediate operands of casts. Cast operators in an integer constant expression shall only convert arithmetic types to integer types, except as part of an operand to the typeof operators,sizeof
operator, oralignof
operator.
â¦
Enumerationsp10 An arithmetic constant expression shall have arithmetic type and shall only have operands that are integer constants literals, floating constants literals, named constants or compound literal constants of arithmetic type, character constants literals, constant
sizeof
expressions whose results are integer constants, andalignof
expressions. Cast operators in an arithmetic constant expression shall only convert arithmetic types to arithmetic types, except as part of an operand to the typeof operators,sizeof
operator, oralignof
operator.
In 6.2.5
Preprocessingp21 An enumeration comprises a set of named integer constant values constants of integer type. â¦
This misses in 6.4.8 (Preprocessing numbers) that some pp-number tokens are already interpreted as integer literals during pre-processing itself.
3 Preprocessing number tokens lexically include all floating and integer constant tokens literals.
Semantics
Character literals4 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 literal or an integer constant token literal. This not withstanding for the evaluation of expressions within conditional source inclusion (6.10.1) and to determine the
limit
parameter for binary resource inclusion (6.10.3), preprocessing numbers shall have the form of an integer literal and are interpreted as such. For the determination of a line number in a#line
directive (6.10.5) digit sequences that also match the requirements for a preprocessing number are interpreted as numbers as well, only that the interpretation is of a decimal integer, even if the leading digit is0
.
Already in the existing text the term âinteger character constantâ is a misnomer, because in fact all character constants have integer type. With the proposed changes âinteger character constantâ, would now become âinteger character literalâ, which is equally confusing. We propose change this term to âsimple character literalâ.
In many places, the term âinteger character constantâ is then currently used as if it would also include UTF-8 character constants/literals. In fact, it seems that the text that speaks of âinteger character constantâ has not been properly updated when introducing UTF-8 character literals. Therefor we propose to introduce a new term ânarrow character literalâ that comprises these two cases.
Macros inA integer simple character constant literal is a sequence of one or more multibyte characters enclosed in single-quotes, as in
âxâ
. A UTF-8 character constant literal is the same, except prefixed byu8
. Together simple and UTF-8 character literal are narrow character literals. Awchar_t
character constant literal is prefixed by the letterL
. A UTF-16 character constant literal is prefixed by the letteru
. A UTF-32 character constant literal is prefixed by the letterU
. Collectively,wchar_t
, UTF-16, and UTF-32 character constants literals are called wide character constants literals. â¦
<stdint.h>
There are inconsistencies in 6.24 what seems to be a confusion of the concepts of âinteger constantâ and âinteger constant expressionâ.
7.22.4 Macros for integer constants constants of integer type
1 The following function-like macros expand to integer constant expressions suitable for initializing objects that have integer types corresponding to types defined in
<stdint.h>
. Each macro name corresponds to a similar type name in 7.22.1.2 or 7.22.1.5.
2 The argument in any instance of these macros shall be an unsuffixed integer constant literal (as defined in 6.4.4.1) with a value that does not exceed the limits for the corresponding type.
3 â¦
7.22.4.1 Macros for minimum-width integer constants constants of integer type
â¦
7.22.4.2 Macros for greatest-width integer constants constants of integer type
changing terminologyâ¦
First do the changes as indicated above. Then in the order as shown
integer character constant simple character literal as above and in 6.4.4.4 p11 and p18 integer character constant narrow character literal otherwise character constant character literal otherwise integer constant integer literal other than in integer constant expression floating constant floating literalRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4