diff mbox

libstdc++/testsuite: Fix a 4402.cc compilation error

Message ID alpine.DEB.1.10.1406102010240.3047@tp.orcam.me.uk
State Accepted
Headers show

Commit Message

Maciej W. Rozycki June 10, 2014, 7:24 p.m. UTC
Hi,

 I needed some diagnostics to sort out a failure observed on one of our 
targets in 27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc in the 
libstdc++ test suite and defined the `TEST_NUMPUT_VERBOSE' macro referred 
there.  That resulted in a compilation error like below:

.../libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc: In function 'void test02()':
.../libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc:48:22: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'std::basic_ostringstream<wchar_t>::__string_type {aka std::basic_string<wchar_t>}')
   cout << "result: " << os.str() << endl;
                      ^

The reason is cout is a plain character stream and does not accept wide 
characters.  An obvious fix is below, verified to produce correct output.

 OK to apply?

2014-06-10  Maciej W. Rozycki  <macro@codesourcery.com>

	libstdc++-v3/
	* testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc
	(test02) [TEST_NUMPUT_VERBOSE]: Use `wcout' rather than `cout'.

  Maciej

gcc-test-libstdcxx-4402.patch

Comments

Jonathan Wakely June 10, 2014, 11:03 p.m. UTC | #1
On 10/06/14 20:24 +0100, Maciej W. Rozycki wrote:
>
>The reason is cout is a plain character stream and does not accept wide
>characters.  An obvious fix is below, verified to produce correct output.
>
> OK to apply?

Yes OK, thanks.
Maciej W. Rozycki June 11, 2014, 12:19 a.m. UTC | #2
On Wed, 11 Jun 2014, Jonathan Wakely wrote:

> > The reason is cout is a plain character stream and does not accept wide
> > characters.  An obvious fix is below, verified to produce correct output.
> > 
> > OK to apply?
> 
> Yes OK, thanks.

 Committed, thanks for your review.

  Maciej
diff mbox

Patch

Index: gcc-fsf-trunk-quilt/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc
===================================================================
--- gcc-fsf-trunk-quilt.orig/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc	2014-05-16 15:58:07.177522688 +0100
+++ gcc-fsf-trunk-quilt/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc	2014-05-19 04:49:29.168978165 +0100
@@ -42,8 +42,8 @@  test02()
   wchar_t largebuf[512];
   swprintf(largebuf, 512, L"%.*Le", prec, val);
 #ifdef TEST_NUMPUT_VERBOSE
-  cout << "expect: " << largebuf << endl;
-  cout << "result: " << os.str() << endl;
+  wcout << "expect: " << largebuf << endl;
+  wcout << "result: " << os.str() << endl;
 #endif
   VERIFY( os && os.str() == largebuf );
 
@@ -58,8 +58,8 @@  test02()
 
   swprintf(largebuf, 512, L"%.*f", 3, val2);
 #ifdef TEST_NUMPUT_VERBOSE
-  cout << "expect: " << largebuf << endl;
-  cout << "result: " << os2.str() << endl;
+  wcout << "expect: " << largebuf << endl;
+  wcout << "result: " << os2.str() << endl;
 #endif
   VERIFY( os2 && os2.str() == largebuf );
 }