public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112820] New: vtable not emitted correctly from module when compiling with -g
@ 2023-12-02  1:38 michael.kenzel at gmail dot com
  2023-12-02 12:31 ` [Bug c++/112820] " nathanieloshead at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: michael.kenzel at gmail dot com @ 2023-12-02  1:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112820

            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 vtable
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=c++23 -fmodules-ts -g -c -x c++ io.ixx
        g++ -std=c++23 -fmodules-ts -g -c -x c++ io-impl.cpp
        g++ -std=c++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): undefined
reference to `vtable for error@io'
        main.cpp:3:(.text._ZNW2io5errorC2Ev[_ZNW2io5errorC5Ev]+0xc): undefined
reference to `vtable for error@io'

Removing the -g from the first two commands resolves the problem, so this seems
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.

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

end of thread, other threads:[~2024-01-27 10:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-02  1:38 [Bug c++/112820] New: vtable not emitted correctly from module when compiling with -g michael.kenzel at gmail dot com
2023-12-02 12:31 ` [Bug c++/112820] " nathanieloshead at gmail dot com
2023-12-04  7:00 ` rguenth at gcc dot gnu.org
2024-01-23  9:46 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:26 ` nshead at gcc dot gnu.org

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