public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace
@ 2023-12-24 19:07 admin at hexadigm dot com
  2023-12-24 19:35 ` [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules) pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: admin at hexadigm dot com @ 2023-12-24 19:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113129
           Summary: "using declaration" not detected as "exported" in
                    exported namespace
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: admin at hexadigm dot com
  Target Milestone: ---

Hi there,

See https://godbolt.org/z/MdToP8nP8 for a demo (self-explanatory and very
short). GCC version fails in top window (see error there), while Clang succeeds
in bottom window (also succeeds in MSVC - haven't test any others).

Issue is that the "using" declaration seen in "Consts.cppm" compiles
successfully but the variable being declared ("Test_v") isn't being exported
even though its "Const" namespace is exported. "Test_v" is therefore
inaccessible to any client that imports the "Consts" module (resulting in the
GCC compiler error seen in the top window).

I don't see any obvious reason why it shouldn't compile however unless it's a
GCC bug (but like so many I'm new to modules and this particular construct is a
fuzzy area - maybe Clang and MSVC got it wrong but read on).

Please note that this technique is very useful since it allows existing C++
headers to be easily used in C++ modules without any changes to the headers
themselves (so correcting it would be highly desirable to many). Users
therefore have the choice to either #include the existing header ("Consts.h" in
this example) or import the module instead ("Consts" in this example). The
module just defers to the header itself by applying "using" declarations as
seen in this example (to export whatever it needs from the header, in this case
"Test_v").

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

* [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules)
  2023-12-24 19:07 [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace admin at hexadigm dot com
@ 2023-12-24 19:35 ` pinskia at gcc dot gnu.org
  2023-12-24 20:05 ` admin at hexadigm dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-24 19:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-12-24
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Please attach the testcase rather than just linking to godbolt . godbolt has an
save feature IIRC.  Also it would be best if not using cmake nor ninja either.
Plain make or shell commands on how to invoke gcc are best the best options so
it is easier to debug.  See https://gcc.gnu.org/bugs/ also.

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

* [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules)
  2023-12-24 19:07 [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace admin at hexadigm dot com
  2023-12-24 19:35 ` [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules) pinskia at gcc dot gnu.org
@ 2023-12-24 20:05 ` admin at hexadigm dot com
  2023-12-25 13:09 ` admin at hexadigm dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: admin at hexadigm dot com @ 2023-12-24 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Larry Smith <admin at hexadigm dot com> ---
@Andrew Thanks for the feedback. I don't work in Unix-like environments though
normally (including Linux) so CMake, make, and shell commands are something I
rarely work with (I specialize on Microsoft platforms). TBH I don't have the
time to look into it and the equivalent Microsoft code wouldn't be appreciated
for GCC I assume (only working with GCC now as the author of
https://github.com/HexadigmSystems/FunctionTraits which is platform neutral so
it targets GCC among others). The issue is very simple though and the test code
very short. The Compiler Explorer link should suffice IMHO unless someone more
experienced than myself on GCC wants to attach those few files in the format
you've requested (whatever is most appropriate in this forum).

Thanks

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

* [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules)
  2023-12-24 19:07 [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace admin at hexadigm dot com
  2023-12-24 19:35 ` [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules) pinskia at gcc dot gnu.org
  2023-12-24 20:05 ` admin at hexadigm dot com
@ 2023-12-25 13:09 ` admin at hexadigm dot com
  2023-12-27 12:15 ` pilarlatiesa at gmail dot com
  2024-01-27 10:28 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: admin at hexadigm dot com @ 2023-12-25 13:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Larry Smith <admin at hexadigm dot com> ---
UPDATE: This issue is presumably the same as this (didn't come across it when I
searched for any similar bugs prior to posting):

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

Agree with Nicolai Josuttis in above post however, issue is important to fix
(modules still under development in GCC presumably).

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

* [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules)
  2023-12-24 19:07 [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace admin at hexadigm dot com
                   ` (2 preceding siblings ...)
  2023-12-25 13:09 ` admin at hexadigm dot com
@ 2023-12-27 12:15 ` pilarlatiesa at gmail dot com
  2024-01-27 10:28 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pilarlatiesa at gmail dot com @ 2023-12-27 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

Pilar Latiesa <pilarlatiesa at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pilarlatiesa at gmail dot com

--- Comment #4 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
$ cat Consts.h

#ifndef CONSTS_H
    #define CONSTS_H

    namespace Consts
    {
        inline constexpr int Test_v = 120;
    }
#endif


$ cat Consts.cppm

module;

#include "Consts.h"

export module Consts;

export namespace Consts
{
    using Consts::Test_v;
}

$ cat Main.cpp

#include <iostream>
import Consts;

int main()
{
    std::cout << Consts::Test_v;

    return 0;
}


$ g++ -std=c++20 -fmodules-ts -x c++ -c Consts.cppm

$ g++ -std=c++20 -fmodules-ts Consts.o Main.cpp
Main.cpp: In function ‘int main()’:
Main.cpp:7:26: error: ‘Test_v’ is not a member of ‘Consts’
    7 |     std::cout << Consts::Test_v;
      |                          ^~~~~~


N.B. I also believe is a dup of pr109679

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

* [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules)
  2023-12-24 19:07 [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace admin at hexadigm dot com
                   ` (3 preceding siblings ...)
  2023-12-27 12:15 ` pilarlatiesa at gmail dot com
@ 2024-01-27 10:28 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-01-27 10:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
                 CC|                            |nshead at gcc dot gnu.org
         Resolution|---                         |DUPLICATE

--- Comment #5 from Nathaniel Shead <nshead at gcc dot gnu.org> ---


*** This bug has been marked as a duplicate of bug 109679 ***

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

end of thread, other threads:[~2024-01-27 10:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-24 19:07 [Bug c++/113129] New: "using declaration" not detected as "exported" in exported namespace admin at hexadigm dot com
2023-12-24 19:35 ` [Bug c++/113129] "using declaration" not detected as "exported" in exported namespace (C++ modules) pinskia at gcc dot gnu.org
2023-12-24 20:05 ` admin at hexadigm dot com
2023-12-25 13:09 ` admin at hexadigm dot com
2023-12-27 12:15 ` pilarlatiesa at gmail dot com
2024-01-27 10:28 ` 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).