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

* [Bug c++/115194] [modules] "reference to <symbol> is ambiguous" when multiple paths to same symbol exist through module
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2024-06-13  2:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-06-13
     Ever confirmed|0                           |1

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

* [Bug c++/115194] [modules] "reference to <symbol> is ambiguous" when multiple paths to same symbol exist through module
  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
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-13 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:8878fecc251762bc32c24e659695557797e03fd9

commit r15-1296-g8878fecc251762bc32c24e659695557797e03fd9
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 12 21:44:10 2024 -0400

    c++/modules: multiple usings of the same decl [PR115194]

    add_binding_entity creates an OVERLOAD to represent a using-declaration in
    module purview of a declaration in the global module, even for
    non-functions, and we were failing to merge that with the original
    declaration in name lookup.

    It's not clear to me that building the OVERLOAD is what should be
happening,
    but let's work around it for now pending an overhaul of using-decl handling
    for c++/114683.

            PR c++/115194

    gcc/cp/ChangeLog:

            * name-lookup.cc (name_lookup::process_module_binding): Strip an
            OVERLOAD from a non-function.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/using-23_a.C: New test.
            * g++.dg/modules/using-23_b.C: New test.

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

* [Bug c++/115194] [modules] "reference to <symbol> is ambiguous" when multiple paths to same symbol exist through module
  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
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2024-06-13 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.

^ 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).