This function was supposed to check whether the parameter's value type
is the same as path::value_type, and therefore needs no conversion.
Instead it checks whether the parameter is the same as its own value
type, which is never true. This means we incorrectly return a string
view for the case where T is path::string_type, instead of just
returning the string itself. The only place that happens is
path::_S_convert_loc for Windows, where we call _S_convert with a
std::wstring rvalue.
This fixes the condition in _S_convert(T).
libstdc++-v3/ChangeLog:
PR libstdc++/102743
* include/bits/fs_path.h (path::_S_convert(T)): Fix condition
for returning the same string unchanged.
static auto
_S_convert(_Tp __str)
{
- if constexpr (is_same_v<_Tp, typename _Tp::value_type>)
+ if constexpr (is_same_v<typename _Tp::value_type, value_type>)
return __str; // No conversion needed.
#if !defined _GLIBCXX_FILESYSTEM_IS_WINDOWS && defined _GLIBCXX_USE_CHAR8_T
else if constexpr (is_same_v<_Tp, std::u8string>)