Open
Description
Not sure how to title this properly.
The original reproducer is just:
#include <string>
constexpr auto z = std::string("", 0);
with libstdc++.
Using cvise, I get:
template <typename _CharT>
struct basic_string {
constexpr void _M_construct();
constexpr basic_string() {
_M_construct();
}
};
basic_string<char *> a;
template <typename _CharT>
constexpr void basic_string<_CharT>::_M_construct(){}
constexpr basic_string<char*> z{};
https://godbolt.org/z/7PzreExcf
Clang's output is:
<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 basic_string<char*> z{}
| ^~~~~~~~~~~~~~~~~~~~~~
<source>:3:18: note: declared here
3 | constexpr void _M_construct();
| ^
The problem vanishes if a
is commented out, or if basic_string
is not a template anymore.