public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Namespace inside module partition not exported
@ 2021-11-06 22:26 Alexander Christensen
  2021-11-10 13:07 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Christensen @ 2021-11-06 22:26 UTC (permalink / raw)
  To: gcc-bugs

Hi,

This is a rather strange thing, which suspiciously looks like bug. I have a file like this:

```
export module engine.memory : align_type;
export import engine.core;

export I32 get_5()
{
    return 5;
}

export namespace engine::memory
{
    enum class AlignType : I32
    {
        align_1   = 1,
        align_2   = 2,
        align_4   = 4,
        align_8   = 8,
        align_16  = 16,
        align_32  = 32,
        align_64  = 64,
        align_128 = 128,
        align_256 = 256
    };
}
```

I have another translation unit which then imports the module engine.memory. That file can use the function get_5(), but whenever I try to use the namespace engine.memory I get an error that that namespace has not been defined.

If I remove the `export import engine.core` then the namespace is suddenly exported. (!)

So there is an issue with namespaces being hidden (ie. non-exported) whenever a module partition unit imports another module. It does not make any difference if the imported module is export-import'ed or just imported.

Best,
Alexander



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

* Re: Namespace inside module partition not exported
  2021-11-06 22:26 Namespace inside module partition not exported Alexander Christensen
@ 2021-11-10 13:07 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2021-11-10 13:07 UTC (permalink / raw)
  To: Alexander Christensen via Gcc-bugs; +Cc: Alexander Christensen

Hi,

This list is mostly just a bugzilla feed and so isn't widely monitored.
If you're confident the behaviour is a bug then it would be better to
file a bugzilla ticket.  If you're not sure and want to double-check
what the correct behaviour is then it'd be better to ask on gcc-help.

Thanks,
Richard

Alexander Christensen via Gcc-bugs <gcc-bugs@gcc.gnu.org> writes:
> Hi,
>
> This is a rather strange thing, which suspiciously looks like bug. I have a file like this:
>
> ```
> export module engine.memory : align_type;
> export import engine.core;
>
> export I32 get_5()
> {
>     return 5;
> }
>
> export namespace engine::memory
> {
>     enum class AlignType : I32
>     {
>         align_1   = 1,
>         align_2   = 2,
>         align_4   = 4,
>         align_8   = 8,
>         align_16  = 16,
>         align_32  = 32,
>         align_64  = 64,
>         align_128 = 128,
>         align_256 = 256
>     };
> }
> ```
>
> I have another translation unit which then imports the module engine.memory. That file can use the function get_5(), but whenever I try to use the namespace engine.memory I get an error that that namespace has not been defined.
>
> If I remove the `export import engine.core` then the namespace is suddenly exported. (!)
>
> So there is an issue with namespaces being hidden (ie. non-exported) whenever a module partition unit imports another module. It does not make any difference if the imported module is export-import'ed or just imported.
>
> Best,
> Alexander


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

end of thread, other threads:[~2021-11-10 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06 22:26 Namespace inside module partition not exported Alexander Christensen
2021-11-10 13:07 ` Richard Sandiford

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