public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "karl.weber99 at gmx dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107084] New: Program does not link with Standard Library Header Unit but with correspoding #include
Date: Thu, 29 Sep 2022 09:59:27 +0000	[thread overview]
Message-ID: <bug-107084-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107084
           Summary: Program does not link with Standard Library Header
                    Unit but with correspoding #include
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: karl.weber99 at gmx dot net
  Target Milestone: ---

When I compile iostream with 

g++ -fmodules-ts -std=c++20 -c -x c++-system-header iostream

and use "import <iostream>;" the program does not link. When I use "#include
<iostream>" instead, it does link and run.

Commands:

=============================================
g++ -fmodules-ts -std=c++20 -c -x c++ employee.cppm
g++ -fmodules-ts -std=c++20 -c structtest_fmt.cpp
g++ -o structtest structtest_fmt.o employee.o -lfmt
/usr/bin/ld: structtest_fmt.o: in function `main':
structtest_fmt.cpp:(.text+0xfb): undefined reference to
`fmt::v9::vformat(fmt::v9::basic_string_view<char>,
fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender,
char> >)'
/usr/bin/ld: structtest_fmt.cpp:(.text+0x1ae): undefined reference to
`fmt::v9::vformat(fmt::v9::basic_string_view<char>,
fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender,
char> >)'
/usr/bin/ld: structtest_fmt.cpp:(.text+0x261): undefined reference to
`fmt::v9::vformat(fmt::v9::basic_string_view<char>,
fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender,
char> >)'
/usr/bin/ld: structtest_fmt.o: in function
`std::allocator_traits<std::allocator<char>
>::deallocate(std::allocator<char>&, char*, unsigned long)':
structtest_fmt.cpp:(.text._ZNSt16allocator_traitsISaIcEE10deallocateERS0_Pcm[_ZNSt16allocator_traitsISaIcEE10deallocateERS0_Pcm]+0x2d):
undefined reference to `std::__is_constant_evaluated()'
collect2: error: ld returned 1 exit status
=============================================

employee.cppm
=============================================
export module employee;

export struct Employee {
        char firstInitial;
        char lastInitial;
        int  employeeNumber;
        int  salary;
};
=============================================

structtest_fmt.cpp
=============================================
#include <fmt/format.h>
import <iostream>;
import employee;

using namespace std;

int main()
{
        // create and populate an employee
        Employee anEmployee;
        anEmployee.firstInitial = 'J';
        anEmployee.lastInitial = 'D';
        anEmployee.employeeNumber = 42;
        anEmployee.salary = 80000;

        // output the values of an employee
        cout << fmt::format("Employee: {}{}", anEmployee.firstInitial, 
                anEmployee.lastInitial) << endl;
        cout << fmt::format("Number: {}", anEmployee.employeeNumber) << endl;
        cout << fmt::format("Salary: ${}", anEmployee.salary) << endl;
}
=============================================

When I replace the import iostream by the corresponding include statement (and
delete iostream.gcm, then is compiles, links and runs successfully.

             reply	other threads:[~2022-09-29  9:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29  9:59 karl.weber99 at gmx dot net [this message]
2022-09-29 16:46 ` [Bug c++/107084] " pinskia 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-107084-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: link
Be 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).