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

2024-10-26


1540. Use of address constants in constant expressions

Section: 7.7  [expr.const]     Status: NAD     Submitter: Bjarne Stroustrup     Date: 2012-08-16

It appears that the current specification of constant expressions in 7.7 [expr.const] pararaph 2 permits examples like

  constexpr const char* p = "asdf";
  constexpr char ch = p[2];

This seems unnecessarily complicated for both users and implementers. If subscripting were defined directly, rather than in terms of pointer arithmetic and indirection (see issue 1213), we could still support the obvious cases of things like

  constexpr char ch2 = "asdf"[2];

without requiring compilers and users to track the target of address-constant pointers and references.

Rationale (October, 2012):

CWG was comfortable with this implication of the current wording.