public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pilarlatiesa at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98885] New: [modules] forward declaration of classes prevent them from being exported at the point of actual declaration Date: Fri, 29 Jan 2021 11:26:18 +0000 [thread overview] Message-ID: <bug-98885-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98885 Bug ID: 98885 Summary: [modules] forward declaration of classes prevent them from being exported at the point of actual declaration Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pilarlatiesa at gmail dot com Target Milestone: --- $ /home/pililatiesa/GCC-11/bin/g++ -v Using built-in specs. COLLECT_GCC=/home/pililatiesa/GCC-11/bin/g++ COLLECT_LTO_WRAPPER=/home/pililatiesa/GCC-11/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-master/configure --prefix=/home/pililatiesa/GCC-11 --enable-languages=c++ --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20210129 (experimental) (GCC) $ cat A.cpp export module A; class A; // forward declaration export class A {}; // actual declaration $ cat main.cpp import A; int main() { A a; return 0; } $ /home/pililatiesa/GCC-11/bin/g++ -fmodules-ts A.cpp main.cpp -o foo main.cpp: In function ‘int main()’: main.cpp:6:3: error: ‘A’ was not declared in this scope 6 | A a; | ^ It can be worked around by typing "export" in the forward declaration as well. Not sure this is a bug, but it that's the specified behaviour, I’d say it’s very counter-intuitive. For example, this won’t work: $ cat A.cpp export module A; class B; export class A { void f(B const &) const; }; $ cat B.cpp export module B; class A; export class B { void f(A const &) const; }; $ cat A-impl.cpp module A; import B; void A::f(B const &) const {} $ cat B-impl.cpp module B; import A; void B::f(A const &) const {}
next reply other threads:[~2021-01-29 11:26 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-29 11:26 pilarlatiesa at gmail dot com [this message] 2021-01-29 13:08 ` [Bug c++/98885] " nathan at gcc dot gnu.org 2021-01-29 13:45 ` pilarlatiesa at gmail dot com 2021-01-29 13:51 ` nathan at gcc dot gnu.org 2021-01-29 14:21 ` pilarlatiesa at gmail dot com 2021-01-29 15:58 ` nathan at gcc dot gnu.org 2021-01-29 16:11 ` pilarlatiesa at gmail dot com 2021-01-29 16:51 ` nathan at gcc dot gnu.org 2021-01-30 9:34 ` pilarlatiesa at gmail dot com 2021-02-03 18:58 ` nathan at gcc dot gnu.org 2021-09-15 11:50 ` redi at gcc dot gnu.org 2023-11-24 1:31 ` cvs-commit at gcc dot gnu.org 2024-02-11 14:21 ` nshead at gcc dot gnu.org 2024-02-11 14:21 ` nshead at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-98885-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).