<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73232>73232</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang reports an undefined function that has been defined
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
libstdc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tbaederr
</td>
</tr>
</table>
<pre>
Not sure how to title this properly.
The original reproducer is just:
```c++
#include <string>
constexpr auto z = std::string("", 0);
```
with libstdc++.
Using cvise, I get:
```c++
template <typename _CharT>
struct basic_string {
constexpr void _M_construct();
constexpr basic_string() {
_M_construct();
}
};
void operators() {
basic_string<char *>{};
}
template <typename _CharT>
constexpr void basic_string<_CharT>::_M_construct(){}
constexpr basic_string<char*> z{};
```
https://godbolt.org/z/7PzreExcf
Clang's output is:
```console
<source>:18:16: error: constexpr variable 'z' must be initialized by a constant expression
18 | constexpr auto z = basic_string<char *>();
| ^ ~~~~~~~~~~~~~~~~~~~~~~
<source>:6:5: note: undefined function '_M_construct' cannot be used in a constant expression
6 | _M_construct();
| ^
<source>:18:20: note: in call to 'basic_string()'
18 | constexpr auto z = basic_string<char *>();
| ^~~~~~~~~~~~~~~~~~~~~~
<source>:3:18: note: declared here
3 | constexpr void _M_construct();
| ^
```
The problem vanishes if `operators()` is commented out, or if `basic_string` is not a template anymore.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVcGS4jgM_RrnohoqsQmBQw40NFV72K09zJ67nFgQTzl2ylZ6Bg777VtOmCZh6N4-jMs4xJElvSdLkiHok0UsWf7E8n0ie2qcL6mSqND7pHLqXP7lCELvERr3HcgBaTII1OgAnXcdenNesHTP0u24fm0QnNcnbaUBj513qq_Rgw7wrQ_ExHYqzVbpOGvGn-Icd7nQtja9QmBiF8hre2LiefxYOxsIf3QeZE8OLsDEHgKpqFlsr8J8zTgf5g5SxjdMPN0ZHF-_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