When I try to use std::filesystem::u8path() I get a deprecation message. It recommends replacing u8path() with path((const char8_t*)&*source) The code it recommends is undefined behaviour (See https://stackoverflow.com/a/57453713/14516046 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114925).
P3364 "Remove Deprecated u8path overloads From C++26" https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3364r0.pdf recommends replacing u8path with: inline auto myu8path(const char* s) { std::u8string u8s(s, s+std::strlen(s)); return std::filesystem::path(u8s); } libstdc++-v3/ChangeLog: PR libstdc++/PR114925 * include/bits/fs_path.h : Improve u8path deprecation warning --- libstdc++-v3/include/bits/fs_path.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 62af6d98bb7..cc41e22aa25 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -838,7 +838,7 @@ namespace __detail template<typename _Source, typename _Require = __detail::_Path<_Source>, typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>> - _GLIBCXX20_DEPRECATED_SUGGEST("path((const char8_t*)&*source)") + _GLIBCXX20_DEPRECATED_SUGGEST("path(u8string(source, source+strlen(source)))") inline path u8path(const _Source& __source) { -- 2.47.1