[Bug c++/124928] [modules] "was not declared in this scope" error

d7d1cd at mail dot ru via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124928

--- Comment #3 from d7d1cd <d7d1cd at mail dot ru> ---
Minimal example:
    $ cat foo.h
    #pragma once
    class Foo {};

    $ cat foo.ixx
    module;
    #include "foo.h"
    export module M : foo;
    export using ::Foo;

    $ cat bar.h
    #pragma once
    #include "foo.h"
    struct Bar {
        Foo f;
    };

    $ cat bar.ixx
    module;
    #include "bar.h"
    export module M : bar;
    export using ::Bar;

    $ cat module.ixx
    export module M;
    export import : bar;
    export import : foo;

    $ cat main.cc
    import M;
    int main() { 
        Foo f;
    }

Compilation and error:
    $ g++ -std=c++23 -fmodules foo.ixx bar.ixx module.ixx main.cc
    main.cc: In function ‘int main()’:
    main.cc:5:5: error: ‘Foo’ was not declared in this scope
        5 |     Foo f;
          |     ^~~
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.