https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86369
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Another possibility would be to detect it in cxx_eval_binary_expression before calling fold_binary_loc and punt. But, the constant evaluation actually doesn't track whether it is the same or different evaluation of the same string literal, so not optimizing it would on the other side mean we'd reject valid code. Consider constexpr auto name3(const char *p) { return p; } int main() { constexpr auto p1 = "test3"; constexpr auto p2 = "test4"; constexpr auto b1 = (name3(p1) == name3(p1)); // should be true constexpr auto b2 = (name3(p1) == name3(p2)); // should be false } Note, latest clang++ seems to accept b1 in both #c0 and #c6 testcases and reject b2 in both.