[PATCH] libstdc++: Add (generic_)display_string and (generic_)native_enconded_string to filesstem::path
Jonathan Wakely
jwakely@redhat.com
Tue Jun 2 20:10:52 GMT 2026
Typos in the subject line:
"encoded"
"filesystem"
On Thu, 28 May 2026 at 09:50 +0200, Tomasz Kamiński wrote:
>Futhermore string and generic_string method as marked as deprecated
"Furthermore"
>in C++26 mode.
>
>This implements the P2319R5 "Prevent path presentation problem" paper,
>with the rename of system_encoded_string from LWG4512,
>"The system_encoded_string() and generic_system_encoded_string() member
>functions of std::filesystem::path are misnamed".
>
>The wording defines the display_string and generic_display_string
>int terms of call of format with format string "{}" and "{:g}"
"in terms of"
Let's say "call of std::format" because otherwise "call of format with
format string" seems repetitive and a bit confusing.
>respectively. This patch inlines the effects of above, by either
>returning native() or generic_string<value_type>() direclty
"directly"
>(if value_type is char), or string constructed __unicode::_Utf_view
>of above (when value_type is wchar_t).
>
>As we currently assume that char encoding is always UTF-8, the outputs
>of (generic_)native_encoded string and (generic_)display_string
>are equivalent. However, the former may be adjusted in future.
>
>libstdc++-v3/ChangeLog:
>
> * include/bits/fs_path.h (path::string, path::generic_string):
> Add deprected attribute in C++26 via _GLIBCXX26_DEPRECATED_SUGGEST.
"deprecated"
> (path::display_string, path::native_encoded_string)
> (path::generic_display_string, path::generic_native_encoded_string)
> [__glibcxx_format_path >= 202506L]: Define.
> * include/bits/version.def (format_path): Bump to 202506.
> * include/bits/version.h: Regenerate.
> * testsuite/util/testsuite_fs.h (__gnu_test::compare_paths):
> Ignored deprecated declarations warning.
> * testsuite/27_io/filesystem/filesystem_error/cons.cc:
> Disable -Wdeprecated-declarations warning with pragmas.
> * testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
> * testsuite/27_io/filesystem/operations/copy_file.cc: Likewise.
> * testsuite/27_io/filesystem/path/concat/strings.cc: Likwise.
> * testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
> * testsuite/27_io/filesystem/operations/temp_directory_path.cc:
> Likewise.
> * testsuite/27_io/filesystem/path/decompose/root_directory.cc:
> Likewise.
> * testsuite/27_io/filesystem/path/generic/generic_string.cc:
> Likewise.
> * testsuite/27_io/print/1.cc: Likewise.
> * testsuite/27_io/print/2.cc: Likewise.
> * testsuite/27_io/print/3.cc: Likewise.
> * testsuite/27_io/filesystem/path/append/source.cc:
> Add dg-warning for deprecated functions use.
> * testsuite/27_io/filesystem/path/decompose/stem.cc: Likewise.
> * testsuite/27_io/filesystem/path/native/string-char8_t.cc:
> Likewise.
> * testsuite/27_io/filesystem/path/generic/display_native_string.cc:
> New test.
> * testsuite/27_io/filesystem/path/native/display_native_string.cc:
> New test.
>---
>I used dg-warning when there was one/two calls to update, and
>addign it didn't make lines excessivelly long. The display_native_string
>test make sure that warning appear.
>
>Tested on x86_64-linux. *filesystem/path* also tested on MinGW and WINE
>locally. OK for trunk?
OK with the typos fixed, thanks.
More information about the Libstdc++
mailing list