public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3458] libstdc++: Add test for illegal pointer arithmetic in format [PR111102]
@ 2023-08-24 12:45 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-08-24 12:45 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:7564fe98657ad5ede34bd08f5279778fa8698865

commit r14-3458-g7564fe98657ad5ede34bd08f5279778fa8698865
Author: Paul Dreik <gccpatches@pauldreik.se>
Date:   Thu Aug 24 11:43:43 2023 +0100

    libstdc++: Add test for illegal pointer arithmetic in format [PR111102]
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/111102
            * testsuite/std/format/string.cc: Check wide character format
            strings with out-of-range widths.

Diff:
---
 libstdc++-v3/testsuite/std/format/string.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libstdc++-v3/testsuite/std/format/string.cc b/libstdc++-v3/testsuite/std/format/string.cc
index fef55b9bcd9e..a472f8d588c2 100644
--- a/libstdc++-v3/testsuite/std/format/string.cc
+++ b/libstdc++-v3/testsuite/std/format/string.cc
@@ -16,6 +16,18 @@ is_format_string_for(const char* str, Args&&... args)
   }
 }
 
+template<typename... Args>
+bool
+is_format_string_for(const wchar_t* str, Args&&... args)
+{
+  try {
+    (void) std::vformat(str, std::make_wformat_args(args...));
+    return true;
+  } catch (const std::format_error&) {
+    return false;
+  }
+}
+
 void
 test_no_args()
 {
@@ -124,8 +136,11 @@ test_format_spec()
 
   // Maximum integer value supported for widths and precisions is USHRT_MAX.
   VERIFY( is_format_string_for("{:65535}", 1) );
+  VERIFY( is_format_string_for(L"{:65535}", 1) );
   VERIFY( ! is_format_string_for("{:65536}", 1) );
+  VERIFY( ! is_format_string_for(L"{:65536}", 1) );
   VERIFY( ! is_format_string_for("{:9999999}", 1) );
+  VERIFY( ! is_format_string_for(L"{:9999999}", 1) );
 }
 
 void

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-24 12:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 12:45 [gcc r14-3458] libstdc++: Add test for illegal pointer arithmetic in format [PR111102] Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).