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

            Bug ID: 122279
           Summary: Non-exported using-directives not visible across TUs
                    within the same module
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gulackeg at gmail dot com
  Target Milestone: ---

Test code:

    // https://godbolt.org/z/fxsP1Wejh

    // M.cpp
    export module M;
    namespace N {
    void f() {}
    }
    using namespace N;
    export void g();

    // M-impl.cpp
    module M;
    void g() { 
      // - Clang: OK
      // - GCC: error: 'f' was not declared in this scope
      f(); 
    }

GCC accepts the code if we add `export` to `using namespace N;`. But according
to [basic.lookup.general]/2.3[1]:

    - either *X* is exported or else *D* and *L* are part of the same
      module and *X* does not inhabit a namespace with internal linkage
      or declare a name with internal linkage.

`export` is not needed here because the TUs `M.cpp` and `M-impl.cpp` are part
of the same module `M`.

[1]: https://timsong-cpp.github.io/cppwp/n4950/basic.lookup.general#2.3

Reply via email to