-
Notifications
You must be signed in to change notification settings - Fork 15k
Closed
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules
Description
Given the following two valid files:
module;
namespace n {
struct s { };
void operator+(s, int) {
}
} // namespace n
export module a;
export template<typename T>
void a(T x) {
n::s() + x;
}
module;
export module b;
import a;
void b() {
a(0);
}
When compiled with
clang++ -std=c++20 -x c++-module a.cpp --precompile -o a.pcm
clang++ -std=c++20 -x c++-module b.cpp --precompile -o b.pcm -fmodule-file=a.pcm
causes Clang to fail with
In file included from b.cpp:1:
a.cpp:16:9: error: invalid operands to binary expression ('n::s' and 'int')
n::s() + x;
~~~~~~ ^ ~
b.cpp:8:2: note: in instantiation of function template specialization 'a<int>' requested here
a(0);
^
1 error generated.
In practice, this comes up with code like std::string() + some_custom_to_string(my_type)
. Calling code needs to #include <string>
in their module, even though they know nothing about std::string
in the called function.
Metadata
Metadata
Assignees
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules