Created on 2025-03-07.00:00:00 last changed yesterday
Proposed resolution (approved by CWG 2025-09-12):
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;
- ...
(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)?
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-09-13 07:51:41 | admin | set | messages: + msg8099 |
2025-09-13 07:51:41 | admin | set | status: open -> tentatively ready |
2025-03-07 00:00:00 | admin | create |