Date: Sun, 16 Feb 2025 15:02:31 +1100
Hi,
[expr.const] has:
---------------------------------------------------------------
A variable is potentially-constant if it is constexpr or it has reference or
non-volatile const-qualified integral or enumeration type.
A constant-initialized potentially-constant variable V is usable in constant
expressions at a point P if Vās initializing declaration D is reachable from P and
ā V is constexpr,
ā V is not initialized to a TU-local value, or
ā P is in the same translation unit as D.
---------------------------------------------------------------
I don't get the wording here.
In this example, 'v' is potentially-constant because it has non-volatile
const-qualified integral type.
'v' is not a 'constexpr', so it's saying 'v' is not usable in constant
expressions here:
*****************************
const int v = 1;
int array[v];
int main()
{
}
*****************************
The earliest paper i could find that has this wording is 2020/n4868.pdf (a
working draft)
[expr.const] has:
---------------------------------------------------------------
A variable is potentially-constant if it is constexpr or it has reference or
non-volatile const-qualified integral or enumeration type.
A constant-initialized potentially-constant variable V is usable in constant
expressions at a point P if Vās initializing declaration D is reachable from P and
ā V is constexpr,
ā V is not initialized to a TU-local value, or
ā P is in the same translation unit as D.
---------------------------------------------------------------
I don't get the wording here.
In this example, 'v' is potentially-constant because it has non-volatile
const-qualified integral type.
'v' is not a 'constexpr', so it's saying 'v' is not usable in constant
expressions here:
*****************************
const int v = 1;
int array[v];
int main()
{
}
*****************************
The earliest paper i could find that has this wording is 2020/n4868.pdf (a
working draft)
Received on 2025-02-16 04:02:40