From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 81E943858026; Thu, 14 Oct 2021 14:12:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81E943858026 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4404] libstdc++: Fix brainwrong in path::_S_convert(T) [PR102743] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 3d95867ce6867239aa4ae69a9c82915660e1071d X-Git-Newrev: 5e3f88838994b67580594c4679c839fff7cdeba0 Message-Id: <20211014141253.81E943858026@sourceware.org> Date: Thu, 14 Oct 2021 14:12:53 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2021 14:12:53 -0000 https://gcc.gnu.org/g:5e3f88838994b67580594c4679c839fff7cdeba0 commit r12-4404-g5e3f88838994b67580594c4679c839fff7cdeba0 Author: Jonathan Wakely Date: Thu Oct 14 13:20:57 2021 +0100 libstdc++: Fix brainwrong in path::_S_convert(T) [PR102743] 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. Diff: --- 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 c51bfa3095a..a63e4b9ab07 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -625,7 +625,7 @@ namespace __detail static auto _S_convert(_Tp __str) { - if constexpr (is_same_v<_Tp, typename _Tp::value_type>) + if constexpr (is_same_v) 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>)