Closed as not planned
Description
The following code:
#include <string>
constexpr std::string foo{"XX"};
int main() {
}
should compile, but instead it fails with:
test.cc:3:23: error: constexpr variable 'foo' must be initialized by a constant expression
3 | constexpr std::string foo{"XX"};
| ^~~~~~~~~
test.cc:3:23: note: pointer to subobject of heap-allocated object is not a constant expression
/usr/bin/../include/c++/v1/__memory/allocator.h:112:38: note: heap allocation performed here
112 | return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
| ^
1 error generated.
I haven't been able to find anything about this being broken, and available resources list the functionality as available since 15.
This is a musl/libc++/compiler-rt environment, on x86_64 architecture, but probably should not matter. The libc++ has hardened mode on.