[PATCH] libstdc++: Fix failing performance test

Jonathan Wakely jwakely@redhat.com
Tue Sep 29 14:25:24 GMT 2026


This test no longer builds because (file >> line) is ill-formed in
C++20, since r11-2581-g17abcc77341584 which implemented LWG 2499.

There's no reason to use a dynamically-allocated array when the length
is a constant. We can just use an array on the stack.

libstdc++-v3/ChangeLog:

	* testsuite/performance/27_io/ifstream_extract_chars.cc: Use
	stack array instead of dynamic allocation.
---

Tested x86_64-linux.

 .../testsuite/performance/27_io/ifstream_extract_chars.cc      | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc b/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc
index e3c754063279..89c84215108e 100644
--- a/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc
+++ b/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc
@@ -34,7 +34,7 @@ int main()
   const unsigned lines = 200000;
   const unsigned line_length = 200;
 
-  char* line = new char[line_length + 2];
+  char line[line_length + 2];
 
   // Construct data.
   {
@@ -76,7 +76,6 @@ int main()
     clear_counters(time, resource);
   }
 
-  delete[] line;
   unlink(filename);
   return 0;
 }
-- 
2.55.0



More information about the Libstdc++ mailing list