From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6EB2B3858403; Sat, 2 Dec 2023 01:38:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EB2B3858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701481130; bh=92NUEb7IOZiVp3YnjBD3KFh+d6mu76/5biywf6hnppE=; h=From:To:Subject:Date:From; b=K7SWGVZdBUZCd2DCQe8p/Brf8SJjYw4QBsmv1+3NSQXfAKMNSVIy0MefL1qoXA+lU yiHm3zGblek2CE3ka6L6hJrtPoOUj7+3lL4plb3VP2XeOrGbOI6kwFfXn1NQAksrmZ iEJRHCWOANVBUQVG2sePlYeY1YcrbF1uKFfUgg9Y= From: "michael.kenzel at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112820] New: vtable not emitted correctly from module when compiling with -g Date: Sat, 02 Dec 2023 01:38:49 +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: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: michael.kenzel at gmail dot com 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112820 Bug ID: 112820 Summary: vtable not emitted correctly from module when compiling with -g Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: michael.kenzel at gmail dot com Target Milestone: --- When compiling a class with virtual member functions declared in a module interface unit and defined in a module implementation unit with -g, the vta= ble seems to not get emitted correctly, resulting in linker errors. example: // io.ixx export module io; export struct error { virtual const char* what() const noexcept; }; // io-impl.cpp module io; const char* error::what() const noexcept { return "bla"; } // main.cpp import io; int main() { error{}; } compile with g++ -std=3Dc++23 -fmodules-ts -g -c -x c++ io.ixx g++ -std=3Dc++23 -fmodules-ts -g -c -x c++ io-impl.cpp g++ -std=3Dc++23 -fmodules-ts -g -c -x c++ main.cpp g++ main.o io.o io-impl.o produces main.o: in function `error@io::error()': main.cpp:3:(.text._ZNW2io5errorC2Ev[_ZNW2io5errorC5Ev]+0x8): undefi= ned reference to `vtable for error@io' main.cpp:3:(.text._ZNW2io5errorC2Ev[_ZNW2io5errorC5Ev]+0xc): undefi= ned reference to `vtable for error@io' Removing the -g from the first two commands resolves the problem, so this s= eems to be tied to debugging information somehow. While the vtable will only be emitted into io-impl.o, interestingly, it is apparently necessary to remove= -g from both the io-impo.o and the io.o commands for the vtable to be emitted.=