This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/71415] New: std::filesystem::exists that does not throw sets error code if file does not exist
- From: "marejde at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 04 Jun 2016 18:47:55 +0000
- Subject: [Bug libstdc++/71415] New: std::filesystem::exists that does not throw sets error code if file does not exist
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71415
Bug ID: 71415
Summary: std::filesystem::exists that does not throw sets error
code if file does not exist
Product: gcc
Version: 6.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: marejde at gmail dot com
Target Milestone: ---
The following program:
#include <experimental/filesystem>
#include <iostream>
int main(int argc, char *argv[])
{
std::error_code error_code;
bool exists = std::experimental::filesystem::exists("does_not_exist",
error_code);
std::cout << "exists: " << exists << '\n';
std::cout << "error_code.value(): " << error_code.value() << '\n';
std::cout << "error_code.message(): " << error_code.message() << '\n';
std::cout << "error_code operator bool: " << (error_code.value() ? true
: false) << '\n';
return 0;
}
outputs:
exists: 0
error_code.value(): 2
error_code.message(): No such file or directory
error_code operator bool: 1
Which means it is not possible to discern between an error and when the file
does not exist without examining error_code.value(), which is platform
dependent.
Tested on Arch Linux with "gcc (GCC) 6.1.1 20160501".