Let's say that we have a simple main.cpp file which contains only a single call of a function bar which is defined in the module a:
import a;
int main() {
bar(1);
}
Then let's take a look at the module a:
export module a;
namespace N {
struct adl_tag {};
void foo(adl_tag, auto) {}
} // namespace N
export void bar(auto v) {
return foo(N::adl_tag{}, v);
}
There we have an exported function template bar, which invokes N::foo using argument-dependent lookup. The function foo, however, is not exported and is not visible from the outside code.
Godbolt link: https://godbolt.org/z/6Waqbj6zh
clang 21 compiles this project just fine but gcc 15 fails with an error:
In instantiation of ‘void bar@a(auto:2) [with auto:2 = int]’:
error: ‘foo’ was not declared in this scope
Which compiler is right here?
foo(N::adl_tag{}, v)inside bar should trigger ADL then look in namespace N where foo is visible. So ADL should find foofoo. I don't see how such a lookup would succeed. So, I think that GCC is right.