Open davidstone opened 3 years ago
static_assert("abc" != "defg" + 1);
needs to be accepted. However, it seems that static_assert("bcd" != "abcd" + 1);
should be rejected.
Perhaps we need to examine all possible overlapping ways of two string literal objects to detect whether the equality comparison has an unspecified result.
@llvm/issue-subscribers-clang-frontend
Author: David Stone (davidstone)
Extended Description
The following well-formed translation unit
is rejected by clang with the error message
From the standard:
"An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine ([intro.execution]), would evaluate one of the following: ... a three-way comparison ([expr.spaceship]), relational ([expr.rel]), or equality ([expr.eq]) operator where the result is unspecified;" (http://eel.is/c++draft/expr.const#5.23)
And:
If at least one of the operands is a pointer, pointer conversions, function pointer conversions, and qualification conversions are performed on both operands to bring them to their composite pointer type. Comparing pointers is defined as follows:
(http://eel.is/c++draft/expr.eq#3)
The unspecified condition does not apply, so this should be accepted.
See it live: https://godbolt.org/z/vrWh54KM1