From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 090203857829; Tue, 25 Jan 2022 11:15:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 090203857829 From: "f.b.brokken at rug dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104221] New: member functions defined in separate files of classes declared in module partitions won't compile Date: Tue, 25 Jan 2022 11:15:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: f.b.brokken at rug dot nl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2022 11:15:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104221 Bug ID: 104221 Summary: member functions defined in separate files of classes declared in module partitions won't compile Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.b.brokken at rug dot nl Target Milestone: --- The following source file (full.cc) compiles OK: ----------------------------- export module mod:partition; export class Data { int d_value =3D 10; public: int value() const; }; int Data::value() const=20 { return d_value; } void fun(); ----------------------------- The function fun() can be implemented in a separate file, and also compiles= OK (fun.cc): ------------------------- module; #include module mod:partition; using namespace std; void fun() { cout << "hi\n";=20=20=20=20 } ------------------------- When implementing int Data::value() const in a separate file a compilation error results.=20 Here's the modified module interface file (partition.cc): ----------------------------- export module mod:partition; export class Data { int d_value =3D 10; public: int value() const; }; void fun();=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ----------------------------- and the source defining int Data::value() (value.cc): ------------------------ module mod:partition; int Data::value() const { return d_value; } ------------------------ The function void fun() compiles OK. When compiling=20 g++ --std=3Dc++20 -Wall -Wextra -fno-strict-aliasing -fwrapv -c -fmodule= s-ts \ partition.cc fun.cc value.cc using g++-12 on an updated Debian linux system (g++ (Debian 12-20211217-1) 12.0.0 20211217 (experimental) [master r12-6027-g774269aa4b9] the compiler reports: -------------------------------------------------------------------------- value.cc:3:5: error: =E2=80=98Data=E2=80=99 has not been declared 3 | int Data::value() const | ^~~~ value.cc:3:19: error: non-member function =E2=80=98int value()=E2=80=99 can= not have cv-qualifier 3 | int Data::value() const | ^~~~~ value.cc: In function =E2=80=98int value()=E2=80=99: value.cc:5:12: error: =E2=80=98d_value=E2=80=99 was not declared in this sc= ope; did you mean =E2=80=98value=E2=80=99? 5 | return d_value; | ^~~~~~~ | value value.cc: At global scope: value.cc:1:1: warning: not writing module =E2=80=98mod:partition=E2=80=99 d= ue to errors 1 | module mod:partition; | ^~~~~~ -------------------------------------------------------------------------- If any additional information is required, please let me know. Kind regards, Frank.=