public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114868] New: [modules] func declared in GMF and exported via using-decl in module partition is not actually exported
@ 2024-04-26 19:19 m.cencora at gmail dot com
  2024-05-01  7:23 ` [Bug c++/114868] " cvs-commit at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: m.cencora at gmail dot com @ 2024-04-26 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114868
           Summary: [modules] func declared in GMF and exported via
                    using-decl in module partition is not actually
                    exported
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.cencora at gmail dot com
  Target Milestone: ---

$ cat mod.cpp 
export module mod;
export import :part;

export void foo()
{
}

$ cat mod-part.cpp 
module;

#include "bar.hpp"

export module mod:part;

export using ::bar;

export void bar_non_gmf()
{
}

$ cat usage.cpp 
import mod;

int main()
{
    foo();
    bar();
    bar_non_gmf();
}

$ g++ -std=c++2b -fmodules-ts mod-part.cpp mod.cpp usage.cpp
usage.cpp: In function ‘int main()’:
usage.cpp:6:5: error: ‘bar’ was not declared in this scope
    6 |     bar();
      |     ^~~

When I compile mod-part.cpp on its own, it seems that bar symbol is not emitted
in the object file:
$ g++ -std=c++2b -fmodules-ts mod-part.cpp -c -o mod-part.o
$ readelf -s mod-part.o | c++filt

Symbol table '.symtab' contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS mod-part.cpp
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 .text
     3: 0000000000000000    11 FUNC    GLOBAL DEFAULT    1 bar_non_gmf@mod()
     4: 000000000000000b    11 FUNC    GLOBAL DEFAULT    1 initializer for
module mod:part

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

* [Bug c++/114868] [modules] func declared in GMF and exported via using-decl in module partition is not actually exported
  2024-04-26 19:19 [Bug c++/114868] New: [modules] func declared in GMF and exported via using-decl in module partition is not actually exported m.cencora at gmail dot com
@ 2024-05-01  7:23 ` cvs-commit at gcc dot gnu.org
  2024-05-01  7:26 ` nshead at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-01  7:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:0d0215b10dbbe39d655ceda4af283f288ec7680c

commit r15-85-g0d0215b10dbbe39d655ceda4af283f288ec7680c
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Tue Apr 9 21:49:58 2024 +1000

    c++: Propagate using decls from partitions [PR114868]

    The modules code currently neglects to set OVL_USING_P on the dependency
    created for a using-decl, which causes it not to remember that the
    OVL_EXPORT_P flag had been set on it when emitted from the primary
    interface unit. This patch ensures that it occurs.

            PR c++/114868

    gcc/cp/ChangeLog:

            * module.cc (depset::hash::add_binding_entity): Propagate
            OVL_USING_P for using-declarations.

    gcc/testsuite/ChangeLog:

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

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>

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

* [Bug c++/114868] [modules] func declared in GMF and exported via using-decl in module partition is not actually exported
  2024-04-26 19:19 [Bug c++/114868] New: [modules] func declared in GMF and exported via using-decl in module partition is not actually exported m.cencora at gmail dot com
  2024-05-01  7:23 ` [Bug c++/114868] " cvs-commit at gcc dot gnu.org
@ 2024-05-01  7:26 ` nshead at gcc dot gnu.org
  2024-05-24 14:33 ` cvs-commit at gcc dot gnu.org
  2024-05-24 14:35 ` nshead at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-05-01  7:26 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |nshead at gcc dot gnu.org
                 CC|                            |nshead at gcc dot gnu.org
   Target Milestone|---                         |14.2
   Last reconfirmed|                            |2024-05-01
             Status|UNCONFIRMED                 |ASSIGNED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=114683

--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 15 so far.  Non-functions don't always work, which is largely
tracked in PR c++/114683. We also might not correctly differentiate unscoped
enums from using enum declarations for this purpose, but it's hard to tell
before PR114683 is fixed.

For instance:


  // using_enum_a.cpp
  module;
  namespace foo {
    enum class a { x, y, z };
  }
  export module M:a;
  namespace bar {
    export using enum foo::a;
  }

  // using_enum_b.cpp
  export module M;
  export import :a;

  // using_enum_c.cpp
  import M;
  int main() {
    auto x = bar::x;
  }

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

* [Bug c++/114868] [modules] func declared in GMF and exported via using-decl in module partition is not actually exported
  2024-04-26 19:19 [Bug c++/114868] New: [modules] func declared in GMF and exported via using-decl in module partition is not actually exported m.cencora at gmail dot com
  2024-05-01  7:23 ` [Bug c++/114868] " cvs-commit at gcc dot gnu.org
  2024-05-01  7:26 ` nshead at gcc dot gnu.org
@ 2024-05-24 14:33 ` cvs-commit at gcc dot gnu.org
  2024-05-24 14:35 ` nshead at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-24 14:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Nathaniel Shead
<nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:782ad2033ea0709a25ef3e899cbb9491406146d5

commit r14-10241-g782ad2033ea0709a25ef3e899cbb9491406146d5
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Tue Apr 9 21:49:58 2024 +1000

    c++: Propagate using decls from partitions [PR114868]

    The modules code currently neglects to set OVL_USING_P on the dependency
    created for a using-decl, which causes it not to remember that the
    OVL_EXPORT_P flag had been set on it when emitted from the primary
    interface unit. This patch ensures that it occurs.

            PR c++/114868

    gcc/cp/ChangeLog:

            * module.cc (depset::hash::add_binding_entity): Propagate
            OVL_USING_P for using-declarations.

    gcc/testsuite/ChangeLog:

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

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
    (cherry picked from commit 0d0215b10dbbe39d655ceda4af283f288ec7680c)

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

* [Bug c++/114868] [modules] func declared in GMF and exported via using-decl in module partition is not actually exported
  2024-04-26 19:19 [Bug c++/114868] New: [modules] func declared in GMF and exported via using-decl in module partition is not actually exported m.cencora at gmail dot com
                   ` (2 preceding siblings ...)
  2024-05-24 14:33 ` cvs-commit at gcc dot gnu.org
@ 2024-05-24 14:35 ` nshead at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-05-24 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
And fixed for GCC 14.2.

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

end of thread, other threads:[~2024-05-24 14:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26 19:19 [Bug c++/114868] New: [modules] func declared in GMF and exported via using-decl in module partition is not actually exported m.cencora at gmail dot com
2024-05-01  7:23 ` [Bug c++/114868] " cvs-commit at gcc dot gnu.org
2024-05-01  7:26 ` nshead at gcc dot gnu.org
2024-05-24 14:33 ` cvs-commit at gcc dot gnu.org
2024-05-24 14:35 ` nshead 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).