<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/105796>105796</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang fails to compile consteval because of conflicting rule for variable arrays (?)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
socketpair
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/3K45T9cTP
```cpp
#include <algorithm>
#include <array>
template <std::size_t N>
struct CompTimeStr {
std::array<char, N> store;
consteval CompTimeStr(const char (&str)[N]) {
std::copy_n(str, store.size(), store.data());
}
template <std::size_t N2>
consteval CompTimeStr<N + N2 - 1> operator+(
const CompTimeStr<N2> str) const {
char newchar[size() + str.size() + 1];
std::copy_n(data(), size(), newchar);
std::copy_n(str.data(), str.size() + 1, newchar + size());
return newchar;
}
consteval std::size_t size() const { return store.size() - 1; }
consteval const char* data() const { return store.data(); }
};
template <std::size_t s1, std::size_t s2>
consteval auto operator+(const char (&str)[s2], CompTimeStr<s1> fs) {
return CompTimeStr<s2>(str) + fs;
}
template <CompTimeStr str>
consteval auto addBar() {
return str + str;
}
int main() {
constexpr CompTimeStr str = addBar<"foo">();
return str.size();
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VdFuqzgQ_ZrhxWpExoHAAw-FbF5Wqlbavl8ZYxLvGoxs093er7-yIYHQ5koVjcb2mXPOzNjMWnnphSggKSE5RWx0V20Kq_m_wg1MmqjWzWdxdW6wQF8Bz4Dni25qrdxOmwvg-Sfgmf55SN5z_v4XxCeIX-dvGk9_fBjmCFLZczU2ggCtmLpoI921A_rHt-vGsM9lLXyd6AbFXFi3rvGU6KuVP8UPR97ue60zI3ek0t3wLjvxtzMEjuW0Rggh95NziopfmQGsAgSxThsBtFzn9ae47q0TH0ytgQGzECceggBmgKn14RyS8g2SE2D-mPyBANfD548eMAtnqin3zgsKUPkSa5hjt1h-Z-fB4HjaUv2tTXj36bkqWr0RwJK8IXkhe--KHoRhThvA0tN4kDM5sDmPk5feinnDFxuCZ734L9iflIvskNs6s9uE9t7Qu_avLq5Nqsijjbc8G_eelmO3AfuOzQI7MV4l_JrFCDea_s7jvvxN_ZaibKu3onA39Ya8bZ6pdOWS4BF66VvAV7KofQa88mMN6n88Dsvvus_uJzM30aUnF35sdHrTds9HzWKYtWrThTb0bmu_TOGsbLM70JiHcapxaxdxj3Vaq1zfNP7wEzGsaUrvdvaMjnXm1vrP0srekY7J_juUKd3_gyEbQgTo6ZadVoDYag04q1336oy10FnfRV8Z3W74h2s_fKOmoE1OcxaJYn_EA83zfH-MrkVdp8jZPkbRHHmctSxPD3VMOT9kPOWHNJIFxniIM6TxMcnocZfTBmmW1mnc8rqO93CIRcek2in10flHKJLWjqLYx8kxTyPFaqFseNAQuWL9xStNTpEp_IGXerxYOMRKWmcXCCedEkXlt5OWSWWJ04TrbpBKrGamFpyNVhDd-mCrJHeyvxAzKkFabcgHM5LVSpDwstjQpfQMmEejUdtnVLrrWO-47gDPnsj872Uw-h_BHeA5CLOA51nbR4G_AgAA__-6XThP">