https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122712

            Bug ID: 122712
           Summary: ADL search does not occur in a function exported from
                    a module
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d7d1cd at mail dot ru
  Target Milestone: ---

There is a module:
  module;
  // Came here from the header
  namespace N {
    struct S{};
    template <typename T>
    void foo(S, T) {}
  }
  export module M;
  export template <typename T>
  void bar(T x) {
    foo(N::S{}, x);
  }

This module is imported and the function template is used:
  import M;
  int main() { bar(42); }

This program fails to compile with an error (https://godbolt.org/z/b4j5q8o1q):
error: 'foo' was not declared in this scope

It seems to me that when compiling a module, it's entirely possible to use ADL
to find the foo function, make it decl-reachable, and not discard it.

Reply via email to