aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/std
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-11-18 20:56:35 +0000
committerJonathan Wakely <jwakely@redhat.com>2023-11-18 21:42:33 +0000
commit279e407a06cc676d8e6e0bb5755b0a804e05377c (patch)
tree977b79c923f7755b657f5bfd82aefcd77b62e660 /libstdc++-v3/testsuite/std
parent41a5ea4cab2c59f9911325281f7df1d3ae846d48 (diff)
downloadgcc-279e407a06cc676d8e6e0bb5755b0a804e05377c.zip
gcc-279e407a06cc676d8e6e0bb5755b0a804e05377c.tar.gz
gcc-279e407a06cc676d8e6e0bb5755b0a804e05377c.tar.bz2
libstdc++: Check string value_type in std::make_format_args [PR112607]
libstdc++-v3/ChangeLog: PR libstdc++/112607 * include/std/format (basic_format_arg::_S_to_arg_type): Check value_type for basic_string_view and basic_string specializations. * testsuite/std/format/arguments/112607.cc: New test.
Diffstat (limited to 'libstdc++-v3/testsuite/std')
-rw-r--r--libstdc++-v3/testsuite/std/format/arguments/112607.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/std/format/arguments/112607.cc b/libstdc++-v3/testsuite/std/format/arguments/112607.cc
new file mode 100644
index 0000000..19eec76
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/format/arguments/112607.cc
@@ -0,0 +1,30 @@
+// { dg-do compile { target c++20 } }
+
+// PR libstdc++/112607
+// _Normalize does not consider char_type for the basic_string_view case
+
+#include <format>
+
+template<typename T>
+struct Alloc
+{
+ using value_type = T;
+ Alloc() = default;
+ template<typename U>
+ Alloc(const Alloc<U>&) { }
+ T* allocate(std::size_t);
+ void deallocate(T*, std::size_t);
+ bool operator==(const Alloc&) const;
+};
+
+template<typename C>
+using String = std::basic_string<C, std::char_traits<C>, Alloc<C>>;
+
+template<>
+struct std::formatter<String<wchar_t>> : std::formatter<std::string> {
+ auto format(const String<wchar_t>&, auto& ctx) const {
+ return std::formatter<std::string>::format(" ", ctx);
+ }
+};
+
+std::string str = std::format("{}", String<wchar_t>{});