From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A5553858427; Fri, 11 Feb 2022 12:47:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A5553858427 From: "asynts+bugs at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100617] [modules] Exported namespace not visible from outside when the module imports another module that declares the same namespace Date: Fri, 11 Feb 2022 12:47:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: asynts+bugs at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Feb 2022 12:47:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100617 Paul Scharnofske changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |asynts+bugs at gmail dot c= om --- Comment #2 from Paul Scharnofske --- I ran into the same issue and produced a slightly different example: ```c++ // foo.cpp export module foo; import bar; namespace foo { export void foo() { } } ``` ```c++ // bar.cpp export module bar; namespace foo { } ``` ```c++ // baz.cpp export module baz; import foo; import bar; int main() { foo::foo(); } ``` ```none $ ~/.local/lib/gcc-trunk/bin/g++ --version g++ (GCC) 12.0.1 20220211 (experimental) Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ ~/.local/lib/gcc-trunk/bin/g++ -Wall -Wextra -std=3Dc++20 -fmodules-ts ba= r.cpp foo.cpp baz.cpp baz.cpp: In function 'int main()': baz.cpp:8:5: error: 'foo' has not been declared 8 | foo::foo(); | ^~~ baz.cpp: At global scope: baz.cpp:2:8: warning: not writing module 'baz' due to errors 2 | export module baz; | ^~~~~~ ``` https://godbolt.org/z/8zMaq6eqr - In other words, the 'export' specifier doesn't even have to be mentione= d. It is enough if the same namespace is mentioned even if it is completely empty and not exported. - The issue disappears if the 'import bar' is removed from 'foo.cpp', in other words, this only happens if that module is actually imported. It doesn't matter that it's still imported in 'baz.cpp'.=