-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules
Description
This issue has been plaguing me for a while, I've finally managed to reduce it somewhat - not minimal, but the only dependency now is libcxx.
This is perhaps related to the known limitation of #include/import ordering with std, but it's a bit different; it requires both import std
and #include <format>
to repro, but it shows up even with the #include encapsulated into a module, and regardless of the import order in the consuming translation unit.
Compiler Explorer link.
Reproducing for me on both latest trunk and latest release.
// mod_a.cppm
export module mod_a;
import std;
auto something() -> void
{
auto const buf = "a";
auto x = std::format("{}", buf[0]);
}
// mod_b.cppm
module;
#include <format>
export module mod_b;
// source.cpp
import std;
// note: import order not relevant
import mod_a;
import mod_b;
auto func() -> void
{
auto const buf = "a";
auto x = std::format("{}", buf[0]);
}
auto dies() -> void
{
std::string_view weird;
auto x = std::format("{}", weird);
}
Output:
In module 'std' imported from /app/source.cpp:2:
/opt/compiler-explorer/clang-trunk-20250717/bin/../include/c++/v1/__format/format_functions.h:99:30: error: call to implicitly-deleted default constructor of 'formatter<std::__1::basic_string_view<char, std::__1::char_traits<char>>, wchar_t>'
99 | formatter<_Tp, _CharT> __f;
| ^
/opt/compiler-explorer/clang-trunk-20250717/bin/../include/c++/v1/__format/format_functions.h:98:62: note: while substituting into a lambda expression here
98 | __parse_ = [](basic_format_parse_context<_CharT>& __ctx) {
| ^
/opt/compiler-explorer/clang-trunk-20250717/bin/../include/c++/v1/__format/format_functions.h:393:25: note: in instantiation of function template specialization 'std::__format::__compile_time_handle<wchar_t>::__enable<std::__1::basic_string_view<char>>' requested here
393 | __handle.template __enable<_Tp>();
| ^
/opt/compiler-explorer/clang-trunk-20250717/bin/../include/c++/v1/__format/format_functions.h:389:99: note: while substituting into a lambda expression here
389 | static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
| ^
source.cpp:16:26: note: in instantiation of template class 'std::__1::basic_format_string<wchar_t, std::__1::basic_string_view<char> &>' requested here
16 | auto x = std::format("{}", weird);
| ^
/opt/compiler-explorer/clang-trunk-20250717/bin/../include/c++/v1/__format/formatter_string.h:141:63: note: default constructor of 'formatter<std::__1::basic_string_view<char>, wchar_t>' is implicitly deleted because base class '__disabled_formatter' has a deleted default constructor
141 | struct formatter<basic_string_view<char, _Traits>, wchar_t> : __disabled_formatter {};
| ^
/opt/compiler-explorer/clang-trunk-20250717/bin/../include/c++/v1/__format/formatter.h:25:3: note: '__disabled_formatter' has been explicitly marked deleted here
25 | __disabled_formatter() = delete;
| ^
Note the bizarre reference to wchar_t
.
Metadata
Metadata
Assignees
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules