[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#932548: g++-8: g++ fails to compile C++17 programs that use std::filesystem::directory_iterator



Package: g++-8
Version: 8.3.0-6
Severity: important

Dear Maintainer,

* What led up to the situation?

Using std::filesystem::directory_iterator in a C++17 program.

* What exactly did you do (or not do) that was effective (or ineffective)?

Attempt to compile and link the program.

Originally I was trying to build third-party free software, but I wrote
a trivial test case that demonstrates the same behaviour to eliminate
potential CMake configuration issues in the third-party software from
consideration. Here follows the test case source code, called "foo.cc":

#include <filesystem>
#include <string>

int main()
{
    std::filesystem::directory_iterator bob(".");
    for (auto p = begin(bob); p != end(bob); ++p)
    {
        printf("%s\n", p->path().c_str());
    }
    return 0;
}

* What was the outcome of this action?

"g++ -std=c++17 foo.cc" failed at the linking step; shell transcript
follows:

mormegil@phlegethon:~/src/native/foo$ g++ -std=c++17 foo.cc
/usr/bin/ld: /tmp/ccjRDL0f.o: in function `main':
foo.cc:(.text+0x123): undefined reference to `std::filesystem::__cxx11::directory_iterator::operator++()'
/usr/bin/ld: /tmp/ccjRDL0f.o: in function `std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&)':
foo.cc:(.text._ZNSt10filesystem7__cxx1118directory_iteratorC2ERKNS0_4pathE[_ZNSt10filesystem7__cxx1118directory_iteratorC5ERKNS0_4pathE]+0x26): undefined reference to `std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)'
/usr/bin/ld: /tmp/ccjRDL0f.o: in function `std::filesystem::__cxx11::directory_iterator::operator->() const':
foo.cc:(.text._ZNKSt10filesystem7__cxx1118directory_iteratorptEv[_ZNKSt10filesystem7__cxx1118directory_iteratorptEv]+0x14): undefined reference to `std::filesystem::__cxx11::directory_iterator::operator*() const'
/usr/bin/ld: /tmp/ccjRDL0f.o: in function `std::filesystem::__cxx11::path::path<char [2], std::filesystem::__cxx11::path>(char const (&) [2], std::filesystem::__cxx11::path::format)':
foo.cc:(.text._ZNSt10filesystem7__cxx114pathC2IA2_cS1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5IA2_cS1_EERKT_NS1_6formatE]+0x5e): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status
mormegil@phlegethon:~/src/native/foo$ 

* What outcome did you expect instead?

I expected g++ to compile and link my test case included in this email
and also to compile and link the large third-party free software package
(the Eternity Engine, a fork of the libre source code for Doom).

-- System Information:
Debian Release: 10.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-5-amd64 (SMP w/12 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages g++-8 depends on:
ii  gcc-8            8.3.0-6
ii  gcc-8-base       8.3.0-6
ii  libc6            2.28-10
ii  libgmp10         2:6.1.2+dfsg-4
ii  libisl19         0.20-2
ii  libmpc3          1.1.0-1
ii  libmpfr6         4.0.2-1
ii  libstdc++-8-dev  8.3.0-6
ii  zlib1g           1:1.2.11.dfsg-1

g++-8 recommends no packages.

Versions of packages g++-8 suggests:
pn  g++-8-multilib    <none>
pn  gcc-8-doc         <none>
pn  libstdc++6-8-dbg  <none>

-- no debconf information


Reply to: