https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90612
Bug ID: 90612
Summary: std::filesystem::path crash
Product: gcc
Version: 9.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: terra at gnome dot org
Target Milestone: ---
Created attachment 46404
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46404&action=edit
Preprocessed source code
# /usr/local/products/gcc/9.1.0/bin/g++ -std=gnu++2a
-Wl,-rpath,/usr/local/products/gcc/9.1.0/lib64 -lstdc++fs short_fail.C
# ./a.out
Segmentation fault (core dumped)
# /usr/local/products/gcc/9.1.0/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/products/gcc/9.1.0/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/products/gcc/9.1.0/lib/gcc/x86_64-suse-linux/9.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../../gcc-9.1.0/configure --enable-languages=c,c++,fortran
--enable-targets=x86_64-suse-linux,i686-suse-linux
--prefix=/usr/local/products/gcc/9.1.0 --with-gnu-as
--with-as=/usr/local/products/gcc/binutils-2.32/bin/as --with-gnu-ld
--with-ld=/usr/local/products/gcc/binutils-2.32/bin/ld --enable-threads=posix
--enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=pool
x86_64-suse-linux
Thread model: posix
gcc version 9.1.0 (GCC)
# cat short_fail.C
#include <filesystem>
#include <vector>
namespace fs = std::filesystem;
struct ChainStruct {
std::vector<fs::path> directories;
};
struct Foo {
void reset();
void set(std::filesystem::path const &baz);
std::filesystem::path baz;
};
void Foo::reset() {
char const *bar = "/aaa/aaaaa/aaaaaa/aaaa";
std::filesystem::path baz(bar);
set(std::filesystem::path(bar));
}
void Foo::set(std::filesystem::path const &baz) {
this->baz = baz;
}
void moo() {
ChainStruct oink;
oink.directories.emplace_back("/aaaa/aaa/aaaaaaa/aaa");
oink.directories.emplace_back("/aaaa/aaa/aaaaaaa/aaa");
oink.directories.emplace_back("/aaaa/aaa/aaaaaaa/aaa");
oink.directories.emplace_back("/aaaa/aaa/aaaaaaa/aaa");
}
int main() {
Foo foo;
foo.set("/aaaaaaa/aaaa/aaaaa/aaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaa");
foo.reset();
foo.set("/aaaaaaa/aaaa/aaaaa/aaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaa");
foo.reset();
moo();
return 0;
}