This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-09-13


3004. Pointer arithmetic on array of unknown bound

Section: 7.7  [expr.const]     Status: tentatively ready     Submitter: A. Jiang     Date: 2025-03-07

(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)? Reject #2 (MSVC)?

Proposed resolution (approved by CWG 2025-09-12):

Add a bullet after 7.7 [expr.const] bullet 10.15 as follows: