This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] libstdc++/37522


Hi,

a minimal fix for this issue. Sanity-checked on x86_64-linux, committed
to mainline.

Paolo.

////////////////////
2008-10-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/37522
	* config/os/mingw32/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSWPRINTF
	* include/bits/basic_string.h: Guard string conversions with 
	!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) too.
	* testsuite/lib/libstdc++.exp (check_v3_target_string_conversions):
	New.
	* testsuite/lib/dg-options.exp (dg-require-string-conversions): New.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
	Use the latter.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/
	stoull.cc: Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/
	to_string.cc: Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
	Likewise.
Index: include/bits/basic_string.h
===================================================================
*** include/bits/basic_string.h	(revision 141381)
--- include/bits/basic_string.h	(working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 2562,2568 ****
  
  _GLIBCXX_END_NAMESPACE
  
! #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99))
  
  #include <ext/string_conversions.h>
  
--- 2562,2569 ----
  
  _GLIBCXX_END_NAMESPACE
  
! #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99) \
!      && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
  
  #include <ext/string_conversions.h>
  
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 129,136 ****
        VERIFY( test );
        VERIFY( f1 == -1.0f );
      }
- 
- #endif
  }
  
  int main()
--- 129,134 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 157,164 ****
      }
    VERIFY( test );
    VERIFY( ll1 == numeric_limits<long long>::min() );
- 
- #endif
  }
  
  int main()
--- 157,162 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 194,201 ****
      }
    VERIFY( test );
    VERIFY( i1 == 1 );
- 
- #endif
  }
  
  int main()
--- 194,199 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 157,164 ****
      }
    VERIFY( test );
    VERIFY( l1 == numeric_limits<long>::min() );
- 
- #endif
  }
  
  int main()
--- 157,162 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 144,151 ****
      }
    VERIFY( test );
    VERIFY( ull1 == numeric_limits<unsigned long long>::max() );
- 
- #endif
  }
  
  int main()
--- 144,149 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 106,113 ****
        test = false;
      }
    VERIFY( test );
- 
- #endif
  }
  
  int main()
--- 106,111 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 144,151 ****
      }
    VERIFY( test );
    VERIFY( ul1 == numeric_limits<unsigned long>::max() );
- 
- #endif
  }
  
  int main()
--- 144,149 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 27,34 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = true;
    using namespace std;
    
--- 29,34 ----
*************** test01()
*** 55,62 ****
    long double ld2 = -4.0L;
    string six(to_string(ld2));
    VERIFY( six == "-4.000000" );
- 
- #endif
  }
  
  int main()
--- 55,60 ----
Index: testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc
===================================================================
*** testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc	(revision 141381)
--- testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc	(working copy)
***************
*** 1,4 ****
--- 1,6 ----
  // { dg-options "-std=gnu++0x" }
+ // { dg-require-string-conversions "" }
+ 
  // 2008-06-15  Paolo Carlini  <paolo.carlini@oracle.com>
  
  // Copyright (C) 2008 Free Software Foundation, Inc.
***************
*** 29,36 ****
  void
  test01()
  {
- #ifdef _GLIBCXX_USE_C99
- 
    bool test __attribute__((unused)) = false;
    using namespace std;
  
--- 31,36 ----
*************** test01()
*** 129,136 ****
        VERIFY( test );
        VERIFY( d1 == -1.0 );
      }
- 
- #endif
  }
  
  int main()
--- 129,134 ----
Index: testsuite/lib/libstdc++.exp
===================================================================
*** testsuite/lib/libstdc++.exp	(revision 141381)
--- testsuite/lib/libstdc++.exp	(working copy)
*************** proc check_v3_target_nanosleep { } {
*** 1236,1238 ****
--- 1236,1296 ----
      verbose "check_v3_target_nanosleep: $et_nanosleep" 2
      return $et_nanosleep
  }
+ 
+ proc check_v3_target_string_conversions { } {
+     global cxxflags
+     global DEFAULT_CXXFLAGS
+     global et_string_conversions
+ 
+     global tool
+ 
+     if { ![info exists et_string_conversions_target_name] } {
+         set et_string_conversions_target_name ""
+     }
+ 
+     # If the target has changed since we set the cached value, clear it.
+     set current_target [current_target_name]
+     if { $current_target != $et_string_conversions_target_name } {
+         verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
+         set et_string_conversions_target_name $current_target
+         if [info exists et_string_conversions] {
+             verbose "check_v3_target_string_conversions: removing cached result" 2
+             unset et_string_conversions
+         }
+     }
+ 
+     if [info exists et_string_conversions] {
+         verbose "check_v3_target_string_conversions: using cached result" 2
+     } else {
+         set et_string_conversions 0
+ 	
+ 	# Set up and compile a C++0x test program that depends
+         # on the string_conversions facilities to be available.
+         set src string_conversions[pid].cc
+         set exe string_conversions[pid].exe
+ 
+         set f [open $src "w"]
+         puts $f "#include <bits/c++config.h>"
+         puts $f "int main()"
+         puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
+         puts $f "{ return 0; }"
+         puts $f "#endif"
+         close $f
+ 
+         set cxxflags_saved $cxxflags
+         set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+ 
+         set lines [v3_target_compile $src $exe executable ""]
+         set cxxflags $cxxflags_saved
+         file delete $src
+ 
+         if [string match "" $lines] {
+             # No error message, compilation succeeded.
+             set et_string_conversions 1
+         } else {
+             verbose "check_v3_target_string_conversions: compilation failed" 2
+         }
+     }
+     verbose "check_v3_target_string_conversions: $et_string_conversions" 2
+     return $et_string_conversions
+ }
Index: testsuite/lib/dg-options.exp
===================================================================
*** testsuite/lib/dg-options.exp	(revision 141381)
--- testsuite/lib/dg-options.exp	(working copy)
*************** proc dg-require-nanosleep { args } {
*** 124,126 ****
--- 124,135 ----
      }
      return
  }
+ 
+ proc dg-require-string-conversions { args } {
+     if { ![ check_v3_target_string_conversions ] } {
+         upvar dg-do-what dg-do-what
+         set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+         return
+     }
+     return
+ }
Index: config/os/mingw32/os_defines.h
===================================================================
*** config/os/mingw32/os_defines.h	(revision 141381)
--- config/os/mingw32/os_defines.h	(working copy)
***************
*** 1,6 ****
  // Specific definitions for generic platforms  -*- C++ -*-
  
! // Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
--- 1,7 ----
  // Specific definitions for generic platforms  -*- C++ -*-
  
! // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
! // Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
***************
*** 52,55 ****
--- 53,59 ----
  // See libstdc++/20806.
  #define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
  
+ // See  libstdc++/37522.
+ #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
+ 
  #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]