This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-03-10
(From submission #680.)
Consider:
extern const int arr[]; constexpr const int *p = arr + N; // #1 constexpr int arr[2] = {0, 1}; // #2 constexpr int k = *p; // #3
What is the outcome here? Accept for N == 0 and otherwise #1 is non-constant (clang)? Always accept #1, but reject #3 for out-of-bounds accesses (gcc)? Always accept #1, but always reject #3, even for in-bound accesses (EDG)? Rejecct #2 (MSVC)?
Further, we miss a specification when a both a declaration of type "array of unknown bound of T" as well as one of the type "array of N T" is reachable. We should take the latter as the type.
Possible resolution:
Add a bullet after 7.7 [expr.const] bullet 10.15 as follows:
- ...
- a reinterpret_cast (7.6.1.10 [expr.reinterpret.cast]);
- pointer arithmetic (7.6.6 [expr.add]) where one (possibly converted) operand points to the first element of an array of unknown bound and the other (possibly converted) operand is of integral type with non-zero value
- ...
Change in 6.8.1 [basic.types.general] paragraph 6 as follows:
A class type (such as “class X”) can be incomplete at one point in a translation unit and complete later on; the type “class X” is the same type at both points. The declared type of an arrayobjectvariable can be an array of incomplete class type C and therefore incomplete;if the class type is completed later onwherever a definition of C is reachable in the translation unit, the array typebecomesis complete; the array type at those two points is the same type. The declared type of an arrayobjectvariable v can be an array of unknown bound and therefore be incomplete at one point in a translation unit and is completelater onwherever a declaration of v with a known bound is reachable; the array types at those two points (“array of unknown bound of T” and “array of N T”) are different types.