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
The (arguably) expanded treatment of backing arrays and string literals as potentially non-unique objects in issue 2753 lead to the question how the resulting address comparisons are treated during constant evaluation.
Subclause 7.7 [expr.const] bullet 5.24 specifies:
An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine (6.9.1 [intro.execution]), would evaluate one of the following:
- ...
- a three-way comparison (7.6.8 [expr.spaceship]), relational (7.6.9 [expr.rel]), or equality (7.6.10 [expr.eq]) operator where the result is unspecified;
- ...
This phrasing is understood to refer to explicitly unspecified outcomes only. The treatment of an example such as
constexpr bool b = "abc" == "abc";
is unclear, given that identical string literals may or may not yield distinct string literal objects.
The assumption that equality comparison of std::string_view would compare addresses as a short-cut before comparing the character sequence could not be confirmed (23.2.2 [char.traits.require], 23.3.3.8 [string.view.ops] paragraph 12).
CWG in Tokyo 2024-03-22
Different approaches are feasible:
In the latter cases, tag values can be preserved when performing pointer arithmetic.