The following program
#include <initializer_list>
#include <string_view>
inline constexpr std::initializer_list<std::string_view> s = { "" };
int main() {}
compiles with current Clang (12.0.0) but not with current GCC (11.0.0 20201028). With GCC it produces the error
prog.cc:4:67: error: modification of '<temporary>' is not a constant expression
4 | inline constexpr std::initializer_list<std::string_view> s = { "" };
| ^
From [dcl.init.list/5] and the fact that the string_view(char const*) constructor is constexpr, I assume that Clang's behavior is right here.
Is that correct?
Yes, you are correct. It is a GCC bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With