]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[testsuite] tolerate missing std::stold
authorAlexandre Oliva <oliva@adacore.com>
Wed, 21 May 2025 09:20:11 +0000 (06:20 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 21 May 2025 09:20:11 +0000 (06:20 -0300)
basic_string.h doesn't define the non-w string version of std::stold
when certain conditions aren't met, and then a couple of tests fail to
compile.

Guard the portions of the tests that depend on std::stold with the
conditions for it to be defined.

for  libstdc++-v3/ChangeLog

* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Guard non-wide stold calls with conditions for it to be
defined.
* testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc:
Likewise.

libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc

index b64ad0c868345f947353b43ffaa163dbe2bf94a9..dd777c4529a0821f823bb08ce3a0ff173da8f8d2 100644 (file)
 void
 test01()
 {
+  /* If these conditions are not met, basic_string.h doesn't define
+     std::stold(const string&, size_t* = 0), and then the test would
+     fail to compile.  */
+#if (_GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD) \
+  || __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
   bool test = false;
   using namespace std;
 
@@ -106,6 +111,7 @@ test01()
       test = false;
     }
   VERIFY( test );
+#endif
 }
 
 int main()
index b1bc7fbb9d4e1adf419a2b61cb55e1d76bc2c4c7..f694730901edbf2cd56569d42cbf3926200ae03e 100644 (file)
@@ -95,6 +95,11 @@ test01()
 void
 test02()
 {
+  /* If these conditions are not met, basic_string.h doesn't define
+     std::stold(const string&, size_t* = 0), and then the test would
+     fail to compile.  */
+#if (_GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD) \
+  || __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
   ostringstream os;
   long double d = 272.L; // 0x1.1p+8L;
   os << hexfloat << setprecision(1);
@@ -140,6 +145,7 @@ test02()
   cout << "got: " << os.str() << endl;
 #endif
   VERIFY( os && os.str() == "15" );
+#endif
 }
 
 int