Authors: Javier Múgica
Date: 2025-09-29
Submitted against: C23
Status: Open
The text on constant expressions defines an address constant as
An address constant is a null pointer, a pointer to an lvalue designating an object of static storage duration, or a pointer to a function designator; it shall be created explicitly using the unary
&
operator or an integer constant cast to pointer type, or implicitly using an expression of array or function type.
Then, among the possible categories for constant expressions it lists
- an address constant
- an address constant for a complete object type plus or minus an integer constant expression
Consider the following two triplets of expressions, where &a
is
supposed to be an address constant for a complete object type:
&a |
&a +1 +2 |
&a +1 |
1 +&a +2 |
&a +1 +2 |
1 +2 +&a |
Of the three at the left, only the first two ones fall under either of the categories "an address constant" or "an address constant for a complete object type plus or minus an integer constant expression". Of those at the right, only the last one.
By contrast, both the wording for compound literal constant and that
for named constant make explicit mention that recursive application of
the .
member access operator is possible.
By looking at the uses of the term "address constant" throughout the
document we see that there is no need for the concept as separate from
address constant plus or minus an ICE. The only use outside constant
expressions is in the description of the offsetof
operator:
The type and member designator shall be such that given
static type t;then the expression
&(t.
member-designator)
evaluates to an address constant.
and nothing changes here if "address constant for a complete object type plus or minus an integer constant expression" is also called "address constant".
Include the construction "address constant for a complete object type plus or minus an integer constant expression" into the concept "address constant", providing a right definition allowing for recursive addition or subtraction of ICE.
In "Constant expressions", 6.6.1 General, replace the paragraph defining address constant (p. 9 in the post-Brno working draft) by
A null pointer, a pointer to an lvalue designating an object of static storage duration or a pointer to a function designator is an address constant; it is created explicitly using the unary
&
operator or an integer constant cast to pointer type, or implicitly using an expression of array or function type. An address constant for a complete object type plus or minus an integer constant expression is also an address constant.
(Keep the footnote.)
Remove the following item from the list of categories a constant expression may be or evaluate to:
an address constant for a complete object type plus or minus an integer constant expression.