From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 99C863858D1E; Sat, 18 Nov 2023 16:28:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99C863858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700324936; bh=KdmXwTiqlyxQGzbyXrweoSQiqlaZRg47i4GiimR4nUg=; h=From:To:Subject:Date:From; b=x27elYLN951vtrnf4OcGvAKmae1oBFU1kC1O/w/jClTHhlH3wMSrng+FNYpqwuxAH yMm+3EjtrzruSHBbyrmDJm+VFGSYA0ezGvdV4pBJXdlGRMa1K1QFXmnws0spKqMuq/ EtzKuqVn9lXWqjRVT/58LH0PkqP/1Mcdw4CqFB7Y= From: "hewillk at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/112607] New: : _Normalize does not consider char_type for the basic_string_view case Date: Sat, 18 Nov 2023 16:28:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hewillk at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112607 Bug ID: 112607 Summary: : _Normalize does not consider char_type for the basic_string_view case Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- When T in basic_format_arg(T& v) is a specialization of basic_string_view or basic_string, format#arg-6.8 indicates:=20 otherwise, if TD is a specialization of basic_string_view or basic_string a= nd TD=E2=80=8B::=E2=80=8Bvalue_type is char_type, initializes value with basic_string_view(v.data(), v.size()); We need to consider TD=E2=80=8B::=E2=80=8Bvalue_type is char_type. However, libstd++ only uses __is_specialization_of to detect whether T is a specialization of basic_string_view or basic_string (format#L3118-L3121): else if constexpr (__is_specialization_of<_Td, basic_string_view>) return type_identity>(); else if constexpr (__is_specialization_of<_Td, basic_string>) return type_identity>(); This causes basic_format_arg to incorrectly use wstring_view to initialize string_view when customizing std::wstring. https://godbolt.org/z/6Kd16z8qK #include template<> struct std::formatter : std::formatter { auto format(const std::wstring& obj, auto& ctx) const { return std::formatter::format(" ", ctx); } }; int main(){ std::wstring wstr; std::string str =3D std::format("{}", wstr); }=