public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115194] New: [modules] "reference to <symbol> is ambiguous" when multiple paths to same symbol exist through module
@ 2024-05-22 17:40 nickbegg at gmail dot com
  2024-06-13  2:42 ` [Bug c++/115194] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nickbegg at gmail dot com @ 2024-05-22 17:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115194
           Summary: [modules] "reference to <symbol> is ambiguous" when
                    multiple paths to same symbol exist through module
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickbegg at gmail dot com
  Target Milestone: ---

This code example was reduced from Boost's multi_index_container.

When referencing symbols via modules and using statements, gcc gets tripped up
with different routes to the same symbol. 

When #including clean.hpp directly into main.cpp, this compiles ok.:

/// clean.hpp :

namespace NS1 { namespace NS2 {
class Thing {};
} // NS2
using NS2::Thing;
} // NS1

/// modA.mpp:
module;

#include "clean.hpp"

export module modA;

export namespace NS1 {
using ::NS1::Thing;
namespace NS2 {
} }

/// main.cpp:

#if 0
#include "clean.hpp"
#else
import modA;
#endif

using NS1::Thing;
using namespace NS1::NS2;
Thing thing;

///

Tested with gcc trunk / 15.0.0 20240522 (revid
1a5e4dd83788ea4c049d354d83ad58a6a3d747e6)

/home/nick/inst/gcc-trunk-debug/bin/g++   -fdiagnostics-color=always -g
-std=gnu++23 -MD -MT CMakeFiles/moduleMin.dir/main.cpp.o -MF
CMakeFiles/moduleMin.dir/main.cpp.o.d -fmodules-ts
-fmodule-mapper=CMakeFiles/moduleMin.dir/main.cpp.o.modmap -MD
-fdeps-format=p1689r5 -x c++ -o CMakeFiles/moduleMin.dir/main.cpp.o -c
/home/nick/src/moduleMin/main.cpp
/home/nick/src/moduleMin/main.cpp:9:1: error: reference to ‘Thing’ is ambiguous
    9 | Thing thing;
      | ^~~~~
In file included from /home/nick/src/moduleMin/modA.mpp:3,
of module modA, imported at /home/nick/src/moduleMin/main.cpp:4:
/home/nick/src/moduleMin/clean.hpp:5:7: note: candidates are: ‘class
NS1::NS2::Thing@modA’
    5 | class Thing {};
      |       ^~~~~
/home/nick/src/moduleMin/clean.hpp:5:7: note:                 ‘class
NS1::NS2::Thing@modA’

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-13 15:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22 17:40 [Bug c++/115194] New: [modules] "reference to <symbol> is ambiguous" when multiple paths to same symbol exist through module nickbegg at gmail dot com
2024-06-13  2:42 ` [Bug c++/115194] " jason at gcc dot gnu.org
2024-06-13 15:06 ` cvs-commit at gcc dot gnu.org
2024-06-13 15:11 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).