Why does this program fails to compile in C++20? Checked with both GCC and Clang. Assignment to both str2 and str3 fails Compiler explorer link: https://gcc.godbolt.org/z/eEWf4avqW
#include <string>
constexpr std::string fun2() {
return std::string("a string");
}
constexpr std::string fun3() {
using namespace std::literals::string_literals;
return "a string"s;
}
int main() {
constexpr std::string str2 = fun2();
constexpr std::string str3 = fun3();
return 0;
}