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

2024-11-11


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.