<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54578>54578</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang 14.0.0 bug: "undefined reference error" for a consteval function.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yaoxinliu
</td>
</tr>
</table>
<pre>
```
inline consteval unsigned char operator""_UC(const unsigned long long n)
{
return static_cast<unsigned char>(n);
}
inline consteval char f1(auto const octet)
{
return char(octet >> 4_UC);
}
inline constexpr char f2(auto const octet)
{
return char(octet >> 4_UC);
}
int main()
{
auto c1 = f1('A'); // ok
auto c2 = f2('A'); // error
return c1 + c2;
}
```
Compiled with: ```clang++-14 -std=c++20 -stdlib=libc++```, and the error message is:
```undefined reference to `operator"" _UC(unsigned long long)'```
See online demo: [https://godbolt.org/z/WarbWYcfP](https://godbolt.org/z/WarbWYcfP)
StackOverflow question link: https://stackoverflow.com/questions/71634835/why-does-consteval-not-behave-as-expected
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VMFy2yAQ_RrpwsgjI8mSDzrEdnJtZzqdTE8dBCuLBoMLyE769V2B49ip28mpGoQR7O57u_twZ8RLmyzy08g3SX4ntZIaCDfaeTgwRUbt5FaDIHxglpg9WOaNTSjF8f3rOqFNsH2zU0Zv46QTuoxRk3oVFwQfC360mjjPvOTfOXM-KdZXMElxj3GDe7F6jbA5LW7TDOz6Obqx0Zt4QAz34P9JIqDRJhiSCba4J2VI62PQz3t7gqb_BdqTHZNYmOZ26EhgjuE2sRgJre_wjTFJQh9wEPP03oNGD_o3D7AWe37B5DIPhKMrjHGD9bW24rw2u71U2Omj9ENS3JGzFVdMbzEWjmxeksx5gbR43KF52FCywz2cT9tvEHRNmBbEDxDpkh04x7ZApEOUSwZnn1EL6OWkOgs9WNAcCJYDT651TqLQ_5T4VCWs1a00vwAQE6UiYGdCotVq8H4f6IS6bo3ojPIzYzHSwy98H5ntHr_x_nNSbRDx4-ZnOURwz_jTpwPYXpkj-TmC89JogmyeJiLXYd1kbE7GM252uPfq4nBdzxdF2RQVLo_DSyYMuOx88TJtfNbBwA6QMZfhhQAUtIg0UtEWYlksWeqlV9CGBpN5OctnOenGbSgKpbfaEBWHpe-xk-ziovej5hOzWTpa1b4rECpq7E4pKHV4_cn21vxAXvgpncPUcFGVVd2kQ0vzsipp3tFCNJ0ou0W96CoullXBl7DM81SxDpRrsXlIR8ORhBCTMKpNKtGf0rygdd6U1Xw542JeiqJciB6aukajMge8smo28Zg6l9o2UML0HR4q6bx7O2QuSAwCHMbH6zkY274w8zz974xpAG8D-d_o77Lr">