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

--- Comment #3 from Steffen Schuemann <ssh at pobox dot com> ---
Sorry, g++-8 -v:

Using built-in specs.
COLLECT_GCC=g++-8
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20180414-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as
--with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.1 20180414 (experimental) [trunk revision 259383] (Ubuntu
8-20180414-1ubuntu2) 

I see, that LWG defect 2935 addresses this question. But first, my
understanding is a defect in WP status is still not part of the standard, so it
might become part of some C++20 or some TC, but it currently doesn't seem to be
part of C++17 (selected by -std=c++17). I might be wrong with that.

And second, I still I don't really see how this is expected to be used by the
developers usinf std::fs. Without that postcondition you have to do a check for
the directory before using that it, so the "spared" call was simply moved to
the user code. Not testing could lead to harder to track down bugs later on in
a different domain of the software. 

And third, as testing for existence and type can be done with one call, I don't
see the issue raised in the defect about additional system calls in the
implementation on Windows and POSIX. I found this issue while implementing a
closely C++17 compatible filesystem for C++11/14 level compilers on Windows and
POSIX and simply ran my (still growing) test suite against GCCs std::fs where
that case failed, so I thought I just report it. ;-)

I didn't need any extra system calls to detect that situation in my (wip)
implementation. So I just looked into
https://github.com/gcc-mirror/gcc/blob/a2809afdf9560accb06cdb595ce20e32f652a75c/libstdc%2B%2B-v3/src/filesystem/std-ops.cc#L652-L665
and when the fs::file_status result of the fs::status(pp, ec) call tracking the
file_type::not_found elements would have been keept, the
fs::is_directory(s)-call on that last file_status would have been free of any
additional system calls.

Well, this might not be the place to discuss the LWG decision, it just doesn't
look like a helpfull one to me, and it feels like beeing taken based on a false
assumtion about the implementation, so it hurts and it converts a supposed
system call actually not needed to a definitive system call on the user side.

I guess I stick to the current C++17 descritpion and keep the error reporting,
as it seems the way to go for me, and it's still good to know I need to take
care on other implementations, but as I would use the compiler given std::fs
whereever I can (I just don't allways have it), I sure would prefer it to
follow the original wording.

Thank you for pointing me on that LWG defect!

Reply via email to