New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C++20] [Modules] ADL does not work properly for dependent expressions #60488
Comments
@llvm/issue-subscribers-clang-modules |
This looks like a bug indeed. BTW, as a workaround, you can export the
|
Here's a second test case that might be the same problem, might be a different problem. In this example, the dependent expression occurs slightly differently. It looks like this needs the global module fragment to trigger: export module a;
export template<typename T>
void a(T x) {
+x;
} module;
struct s {
};
void operator+(s) {
}
export module b;
import a;
export template<typename T>
void b() {
a(s());
} export module c;
import b;
void c() {
b<int>();
} 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
clang++ -std=c++20 -x c++-module c.cpp --precompile -o c.pcm -fmodule-file=b.pcm fails with
This is reduced from comparing |
Update: the corresponding of the wording is http://eel.is/c++draft/module.context#3. We didn't implement modules' Instantiation context before. So here is the problem. |
Close llvm/llvm-project#60488. Previously, when we instantiate a template, the argument dependent lookup is performed in the context of the instantiation, which implies that the functions not visible in the context can't be found by the argument dependent lookup. But this is not true, according to [module.context]p3, the instantiation context for the implicit instantiation of a template should contain the context of the primary module interface if the template is defined in the module interface unit. Note that the fix didn't implemnet [module.context]p3 precisely, see the comments for example.
Close llvm/llvm-project#60488. Previously, when we instantiate a template, the argument dependent lookup is performed in the context of the instantiation, which implies that the functions not visible in the context can't be found by the argument dependent lookup. But this is not true, according to [module.context]p3, the instantiation context for the implicit instantiation of a template should contain the context of the primary module interface if the template is defined in the module interface unit. Note that the fix didn't implemnet [module.context]p3 precisely, see the comments for example.
Given the following two valid files:
When compiled with
causes Clang to fail with
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 aboutstd::string
in the called function.The text was updated successfully, but these errors were encountered: