[PATCH] PR libstdc++/83306 make filesystem_error no-throw copyable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] PR libstdc++/83306 make filesystem_error no-throw copyable

Jonathan Wakely-3
The class API provides no way to modify the members, so we can share
them between copies of the same object. Copying becomes a simple
reference count update, which doesn't throw.

Also adjust the what() string to allow distinguishing between an empty
path passed to the constructor, and no path.

        PR libstdc++/83306
        * include/bits/fs_path.h (filesystem_error): Move data members into
        pimpl class owned by shared_ptr. Remove inline definitions of member
        functions.
        * src/filesystem/std-path.cc (filesystem_error::_Impl): Define.
        (filesystem_error): Define member functions.
        * testsuite/27_io/filesystem/filesystem_error/cons.cc: New test.
        * testsuite/27_io/filesystem/filesystem_error/copy.cc: New test.

Tested x86_64-linux, committed to trunk.



patch.txt (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR libstdc++/83306 make filesystem_error no-throw copyable

Jonathan Wakely-3
On 28/11/18 16:52 +0000, Jonathan Wakely wrote:

>On 28/11/18 15:27 +0000, Jonathan Wakely wrote:
>>The class API provides no way to modify the members, so we can share
>>them between copies of the same object. Copying becomes a simple
>>reference count update, which doesn't throw.
>>
>>Also adjust the what() string to allow distinguishing between an empty
>>path passed to the constructor, and no path.
>>
>> PR libstdc++/83306
>> * include/bits/fs_path.h (filesystem_error): Move data members into
>> pimpl class owned by shared_ptr. Remove inline definitions of member
>> functions.
>> * src/filesystem/std-path.cc (filesystem_error::_Impl): Define.
>> (filesystem_error): Define member functions.
>> * testsuite/27_io/filesystem/filesystem_error/cons.cc: New test.
>> * testsuite/27_io/filesystem/filesystem_error/copy.cc: New test.
>>
>>Tested x86_64-linux, committed to trunk.
>
>Ops, this broke he TS implementation:
>
>FAIL: experimental/filesystem/operations/remove.cc (test for excess errors)
>Excess errors:
>/home/jwakely/src/gcc/libstdc++-v3/src/filesystem/path.cc:505: undefined reference to `std::filesystem::fs_err_concat(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
>
>Fix coming up ...
Fixed by this patch, committed to trunk.


patch.txt (2K) Download Attachment