https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106932
Bug ID: 106932 Summary: Incorrect behavior of std::filesystem::copy() with overwrite_existing or update_existing options Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: thomas.allen at intel dot com Target Milestone: --- When using std::filesystem::copy_options::overwrite_existing or std::filesystem::copy_options::update_existing as part of a call to std::filesystem::copy(), no destination directory is created, and the source directory is not copied. In addition, no exception is thrown. If neither of these options are specified, the behavior is as expected, creating the destination directory and copying all regular files into it. This appears to be contrary to bullet 4.7.4 in Section 29.11.14.3 of the C++20 spec, where for regular files in a source directory, the effect should be equivalent to passing any options through to a copy_file() call on each file. This bug occurs on SUSE Linux Enterprise Server 12 SP5, running on an Intel Xeon Gold 6136 CPU. Additionally, testing with GCC 10.2.0 and 12.2.0 shows the same issue. The build configuration options used with GCC 11.3.0 specifically were: /nfs/orto/proj/tapeout/cit_rep/ImagingToolsSupport/v2/bootstrap/build/sles12/gcc920/gcc/11.3.0/default/extract/gcc-11.3.0/configure --prefix=/nfs/orto/proj/tapeout/cit_rep/ImagingToolsSupport/v2/bootstrap/install/sles12/gcc920/gcc/11.3.0/default --with-specs='%{!static:%x{-rpath=/nfs/orto/proj/tapeout/cit_rep/ImagingToolsSupport/v2/bootstrap/install/sles12/gcc920/gcc/11.3.0/default/lib64:/nfs/orto/proj/tapeout/cit_rep/ImagingToolsSupport/v2/bootstrap/install/sles12/gcc920/gcc/11.3.0/default/lib}}' --enable-lto The command line which triggers this bug is: g++ -std=c++20 -Wall -o dir_copy_test dir_copy_test.cpp No errors or warnings are emitted by the compiler, and the source directory for the test case is identical in structure to the one shown in the Notes section at https://en.cppreference.com/w/cpp/filesystem/copy, i.e. copy_test/ `-- source |-- file1 |-- file3 `-- subdir `-- file2 To produce the issue: cd copy_test dir_copy_test source dest The preprocessor output for the test code is attached.