public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107084] New: Program does not link with Standard Library Header Unit but with correspoding #include
@ 2022-09-29  9:59 karl.weber99 at gmx dot net
  2022-09-29 16:46 ` [Bug c++/107084] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: karl.weber99 at gmx dot net @ 2022-09-29  9:59 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug c++/107084] Program does not link with Standard Library Header Unit but with correspoding #include
  2022-09-29  9:59 [Bug c++/107084] New: Program does not link with Standard Library Header Unit but with correspoding #include karl.weber99 at gmx dot net
@ 2022-09-29 16:46 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-29 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=99377

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely a dup of bug 99377.

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

end of thread, other threads:[~2022-09-29 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29  9:59 [Bug c++/107084] New: Program does not link with Standard Library Header Unit but with correspoding #include karl.weber99 at gmx dot net
2022-09-29 16:46 ` [Bug c++/107084] " pinskia 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).